I have what I think should be a simple problem, but I can't find the answer anywhere (or it's just late).
I am using many radio buttons on my page. At first I was not specifying a "value" for the radio buttons. However, when submitting the form I get a mySQL error stating that the column can't be null.
Then I read CakePHP Unfilled radio button changed to an unwanted value on submit where I learned radio buttons should never be blank. Fair enough, so I set a default "value" = "-1" for them. The problem, I have then is that if the form validation fails on the page, all the radio buttons are set back to the default value and do not repopulate to what the user had entered. Naturally, if the user makes one mistake on the page, I don't want him to have to fix all the radio buttons again.
With my first approach (where I did not specify a "value") on a form validation error it would automatically repopulate the radio buttons to what the user had entered.
Any suggestions on how to get the radio buttons to repopulate to the user selected values on a validation failure?
FYI, the code for one of the radio buttons I am using is as follow:
$radioForm = $this->Form->radio('Review.' . $fieldName ,array("1"=> "1 ","2"=>"2 ","3"=>"3 ","4"=>"4 ","5"=>"5 ", "-1"=>"N/A"),array('legend'=>'', 'value'=>'-1')); echo $radioForm;