Reputation: 13527
So far I have this:
$radio = new Element\Radio('gender');
$radio->setLabel('What is your gender ?');
$radio->setValueOptions(array(
array(
'0' => 'Female',
'1' => 'Male',
)
));
The problem is, I want a table output like this:
Gender | Description | Button
-------------------------------
Male | The workers | [X]
Female | The peacekeepers | [ ]
So the problem is that I want to associate more information to the individual form elements and alter the standard way the get printed to the screen. If something like this could work, I would be pretty happy:
$radio = new Element\Radio('gender');
$radio->setLabel('What is your gender ?');
$radio->setValueOptions(array(
array(
'0' => 'Female',
'1' => 'Male',
)
));
$radio->setExtraData(array(
array(
'0' => 'The workers',
'1' => 'The peacekeepers',
)
));
That obviously doesn't work. So what is the correct "zend" way to accomplish this?
Upvotes: 0
Views: 157
Reputation: 15053
Instead of providing a plain array, you could add extra information in the value options like this:
$radio->setValueOptions(array(
array(
'value' => '0',
'label' => 'Female',
'description' => 'The peacekeepers',
),
array(
'value' => '1',
'label' => 'Male',
'description' => 'The workers',
)
));
The following step would be to create a custom View Helper for rendering the table, or loop through the options and render the table in the view itself.
Upvotes: 1