thanks for your reply.
For example:
I want to add a new gender for test purposes. (Screens are in German)
But i dont know how to change the items in that dropdownlist.
There are two ways you could change this particular dropdown:
In src/Forms/FormFactory.php there is a createSelectGender() method which defines the gender dropdown system-wide.
You can also change the code in your example from addSelectGender(‘gender’) to addSelect(‘gender’) which makes it a generic select drop-down, and add a fromArray() method to provide the selectable items. The code might look something like this:
`$genderOptions = [
'F' => __('Female'),
'M' => __('Male'),
'Other' => __('Other'),
'Unspecified' => __('Unspecified'),
// Add your new options here
];
$row = $form->addRow();
$row->addLabel('gender', __('Gender'));
$row->addSelect('gender')->fromArray($genderOptions)->required();`
```
Hope this helps! There is some documentation about the Form class here, which may be handy: https://gist.github.com/SKuipers/3a4de3a323ab9d0969951894c29940ae
This just helped me big time, i wanted to limit genders to Male Female only
and it worked like a charm, commenting here for if any one needed this in future, he can find it easily by search.
Hi ub123,
There are two ways you could change this particular dropdown:
In src/Forms/FormFactory.php there is a createSelectGender() method which defines the gender dropdown system-wide.
You can also change the code in your example from addSelectGender(‘gender’) to addSelect(‘gender’) which makes it a generic select drop-down, and add a fromArray() method to provide the selectable items. The code might look something like this:
`$genderOptions = [
'F' => __('Female'),
'M' => __('Male'),
'Other' => __('Other'),
'Unspecified' => __('Unspecified'),
// Add your new options here
];
$row = $form->addRow();
$row->addLabel('gender', __('Gender'));
$row->addSelect('gender')->fromArray($genderOptions)->required();`
```
Hope this helps! There is some documentation about the Form class here, which may be handy: https://gist.github.com/SKuipers/3a4de3a323ab9d0969951894c29940ae
Thanks Aziz for sharing your solution! Be sure to track these kinds of changes in a list (or in a GitHub fork if you are familiar with version control), otherwise they will be replaced the next time you update Gibbon.