I wonder how to add some attributes to select's options in Zend 2. My form element looks like this:
$this->add(array(
'type' => 'Zend\Form\Element\Select',
'name' => 'brand_name',
'options' => array(
'label' => 'Choose brand',
'value_options' => $this->getBrands(),
),
));
<select name="brand_name"><option value="1">aaaa</option></select>
<select name="brand_name"><option value="1" class="test">aaaa</option></select>
I've found a solution, array of parent select value_options should look like this:
foreach ($data as $item) {
$models[] = array(
'label' => $item->model_name,
'attributes' => array('class' => $item->id_brand_list),
'value' => $item->id);
}