I have a simple form with some radio buttons. I want to disable some of the radio buttons, is this possible?
$sixMonths = true;
$twelveMonths = true;
$twentyfourMonths = false;
echo $this->McForm->create('Wizard', array ('url'=>'/wizard/create'));
$options = array('24' => '24 months','12' => '12 months', '6' => '6 months');
$attributes = array('legend' =>false, 'default' => '6');
echo $this->McForm->radio('period', $options, $attributes);
echo $this->McForm->submit('Save');
echo $this->McForm->end();
So in this case I'd like to disable the first radio button and enable the other two.
I know I could probably do it with jQuery, but I'd prefer to do it without using it, is it possible? Any ideas?
Thanks!
You can add a disabled
array in $attributes
that contains the values of the radios:
$attributes = [
'legend' => false,
'default' => '6',
'disabled' => ['6', '24']
];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With