I'm attempting to add data-
values on radio buttons within ZF2. Is it possible to control each of the inputs specified with value_options
?
A typical radio button added to a form:
$this->add(array(
'type' => 'radio',
'name' => 'duration',
'options' => array(
'value_options' => array(
'daily' => 'Daily',
'weekly' => 'Weekly',
'monthly' => 'Monthly',
),
),
));
Ultimately, I would like something like the following, so I can specify individual parameters/options for each radio item:
$this->add(array(
'type' => 'radio',
'name' => 'duration',
'options' => array(
'value_options' => array(
array(
'attributes' => array(
'value' => 'daily',
'data-item' => 'apple'
),
'options' => array(
'label' => 'Daily'
)
),
array(
'attributes' => array(
'value' => 'weekly',
'data-item' => 'orange'
),
'options' => array(
'label' => 'Weekly'
)
),
array(
'attributes' => array(
'value' => 'monthly',
'data-item' => 'pear'
),
'options' => array(
'label' => 'Monthly'
)
),
),
),
));
My reason for wanting the above, is that I want to use JavaScript to change something upon selecting a radio button, so it needs to hold data attributes.
Is anything like this possible yet?