forms - How to add class and diffrent paramter to every option in a dropdown in Zend Framework 2 -


the title clear , want add class , data-imagesrc using custom dropdown :

but code wont

        $this->add(array(         'name'  =>  'require_course_id',         'type'      =>  'zend\form\element\select',         'attributes'    =>  array(          ),         'options'       =>  array(             'label'     =>  'prerequisite',             'value_options' =>  array(array('label'=>'test','class'=>'test-class','data-imagesrc'=>'myimage')),//$this->getprerequisite(),         ),     )); 

if take @ zend\form\view\helper\formselect::renderoptions() able see how each <option> generated (and how supplied configuration merged produce final html string).

provide option tag's 'specification' array attribute key (just select element itself).

$this->add(array(     'name'       =>  'require_course_id',     'type'       =>  'zend\form\element\select',     'attributes' =>  array(),     'options'       => array(       'label'     => 'prerequisite',       'value_options' =>  array(          // each option require, provide it's own specification         array(           'label' => 'option 1 label',           'value' => 'opt1value',           'options' => array(             // value , label can here           ),           'attributes' => array(             // again value , label ok here             'class' => 'test-class',             'data-foo' => 'bar'           ),         ),         // end option 1 specification        ),     ), )); 

Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -