Skip to content

Commit

Permalink
Group: Use FormValidator shortcuts instead of FormValidator:addElement(
Browse files Browse the repository at this point in the history
  • Loading branch information
AngelFQC committed Jun 7, 2023
1 parent 91ecc61 commit c75ff22
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions main/inc/lib/usergroup.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1966,10 +1966,7 @@ public function setForm($form, $type = 'add', $data = [])
$form->addHeader($header);

// Name
$form->addElement('text', 'name', get_lang('Name'), ['maxlength' => 255]);
$form->applyFilter('name', 'trim');

$form->addRule('name', get_lang('ThisFieldIsRequired'), 'required');
$form->addText('name', get_lang('Name'), true, ['maxlength' => 255]);
$form->addRule('name', '', 'maxlength', 255);

// Description
Expand All @@ -1986,13 +1983,12 @@ public function setForm($form, $type = 'add', $data = [])
}

// url
$form->addElement('text', 'url', get_lang('Url'));
$form->applyFilter('url', 'trim');
$form->addText('url', get_lang('Url'), false);

// Picture
$allowed_picture_types = $this->getAllowedPictureExtensions();

$form->addElement('file', 'picture', get_lang('AddPicture'));
$form->addFile('picture', get_lang('AddPicture'));
$form->addRule(
'picture',
get_lang('OnlyImagesAllowed').' ('.implode(',', $allowed_picture_types).')',
Expand All @@ -2003,7 +1999,7 @@ public function setForm($form, $type = 'add', $data = [])
if (isset($data['picture']) && strlen($data['picture']) > 0) {
$picture = $this->get_picture_group($data['id'], $data['picture'], 80);
$img = '<img src="'.$picture['file'].'" />';
$form->addElement('label', null, $img);
$form->addLabel(null, $img);
$form->addElement('checkbox', 'delete_picture', '', get_lang('DelImage'));
}

Expand Down

1 comment on commit c75ff22

@eugedipaolo
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as version 1.11.20

Please sign in to comment.