I am trying to create a custom field form for a template parameter for Joomla 3 by following the instructions on this page. Creating a custom form field type
Here are my codes:
class JFormFieldMy extends JFormField { protected $type = 'my'; public function getInput() { return '<select id="'.$this->id.'" name="'.$this->name.'">'. '<optgroup label="First">'. '<option value="1">One</option>'. '<option value="2">Two</option>'. '<option value="3">Three</option>'. '</optgroup>'. '<optgroup label="Second">'. '<option value="4">Four</option>'. '<option value="5">Five</option>'. '<option value="6">Six</option>'. '</optgroup>'. '</select>'; } }
It works well, the value is saved, but the selected value does not have the selected value = "selected", so the option "One" is always displayed in the drop-down list, when I select / the actual value is "Two",
I read this solution: Joomla 2.5 Custom Field List is not selected on the display , but for the general list type, not for the grouped list that I wanted.
Can anybody help me? thanks
source share