Skip to content

Commit 91ecc61

Browse files
committed
Extrafield: Use FormValidator shortcuts instead of FormValidator:addElement(
1 parent da61f28 commit 91ecc61

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

main/inc/lib/extra_field.lib.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2233,9 +2233,9 @@ public function return_form($url, $action)
22332233
{
22342234
$form = new FormValidator($this->type.'_field', 'post', $url);
22352235

2236-
$form->addElement('hidden', 'type', $this->type);
2236+
$form->addHidden('type', $this->type);
22372237
$id = isset($_GET['id']) ? (int) $_GET['id'] : null;
2238-
$form->addElement('hidden', 'id', $id);
2238+
$form->addHidden('id', $id);
22392239

22402240
// Setting the form elements
22412241
$header = get_lang('Add');
@@ -2247,7 +2247,7 @@ public function return_form($url, $action)
22472247
$defaults = $this->get($id, false);
22482248
}
22492249

2250-
$form->addElement('header', $header);
2250+
$form->addHeader($header);
22512251

22522252
if ('edit' === $action) {
22532253
$translateUrl = api_get_path(WEB_CODE_PATH).'extrafield/translate.php?'
@@ -2259,7 +2259,7 @@ public function return_form($url, $action)
22592259
[get_lang('Name'), $translateButton]
22602260
);
22612261
} else {
2262-
$form->addElement('text', 'display_text', get_lang('Name'));
2262+
$form->addText('display_text', get_lang('Name'));
22632263
}
22642264

22652265
// Field type
@@ -2272,8 +2272,8 @@ public function return_form($url, $action)
22722272
$types,
22732273
['id' => 'field_type']
22742274
);
2275-
$form->addElement('label', get_lang('Example'), '<div id="example">-</div>');
2276-
$form->addElement('text', 'variable', get_lang('FieldLabel'), ['class' => 'span5']);
2275+
$form->addLabel(get_lang('Example'), '<div id="example">-</div>');
2276+
$form->addText('variable', get_lang('FieldLabel'), false);
22772277
$form->addElement(
22782278
'text',
22792279
'field_options',
@@ -2297,23 +2297,23 @@ public function return_form($url, $action)
22972297
get_lang('EditExtraFieldOptions'),
22982298
'extra_field_options.php?type='.$this->type.'&field_id='.$id
22992299
);
2300-
$form->addElement('label', null, $url);
2300+
$form->addLabel(null, $url);
23012301

23022302
if (self::FIELD_TYPE_SELECT == $defaults['field_type']) {
23032303
$urlWorkFlow = Display::url(
23042304
get_lang('EditExtraFieldWorkFlow'),
23052305
'extra_field_workflow.php?type='.$this->type.'&field_id='.$id
23062306
);
2307-
$form->addElement('label', null, $urlWorkFlow);
2307+
$form->addLabel(null, $urlWorkFlow);
23082308
}
23092309

23102310
$form->freeze('field_options');
23112311
}
23122312
}
2313-
$form->addElement(
2314-
'text',
2313+
$form->addText(
23152314
'default_value',
23162315
get_lang('FieldDefaultValue'),
2316+
false,
23172317
['id' => 'default_value']
23182318
);
23192319

@@ -2344,7 +2344,7 @@ public function return_form($url, $action)
23442344
$form->addGroup($group, '', get_lang('FieldLoggeable'), '', false);
23452345
*/
23462346

2347-
$form->addElement('text', 'field_order', get_lang('FieldOrder'));
2347+
$form->addNumeric('field_order', get_lang('FieldOrder'), ['step' => 1, 'min' => 0]);
23482348

23492349
if ('edit' == $action) {
23502350
$option = new ExtraFieldOption($this->type);

0 commit comments

Comments
 (0)