Frequently, I have the need to add some values to a ListField. I know that I can add values to the array.
But that's not my point. It seems pretty handy to me, that the FH could be expanded with an extra textfield to add values.
For example, I have this listField
Brands : On Off
|---------|---------|
| Nike | Puma |
| Adidas | |
| | |
---------------------
But what if I dynamically would like to add the Brand 'Reebok' or 'Converse'. Because, those are the brands I need.
I should modify the array or put new values in the table from where the array has been made of.
// options field
$form->listField ("Options", "options", $options, '', true);
// button to add a option
$form->button(
"Add option",
"btnAddOption",
"onclick='addOption( ".
" elements[\"options_ListOff\"],".
" prompt(\"Enter the value of the field\", \"\"),".
" prompt(\"Enter the text to display of the field\", \"\")".
")'"
);
// button beneath it
$form->submitButton("Save");
// set the 'commit after form' function
$form->OnCorrect("doRun");