Shouldn't you be calling?
$this->Item->setAttributes(array('value' => ''));
setAttributes in plural?
You should use helpers to create your radio inputs, as they add a hidden value before the radio for those situations when its not checked.
The selected radiobutton cannot be released. Then, I adding selection 'no select' item.
Is it a specification that cannot add the null string(not NULL)? update is OK.
I'm just make a ActiveFormHelper extends FormHelper. It is automatically makes the form tags and the selection items from the database.
SelectItem Model: id int, value string, title string, category ... 1, 1, 1 minute 2, 3, 3 minute 3, 5, 5 minute 4, 10, 10 minute 5, null, no select <- I hope save null string(not NULL)
$this->SelectItem->setAttributes(array('value'=>'', 'title'=>'no select'));
$this->SelectItem->save();
Output from SelectItem.
class ActiveFormInstanceTag extends AkFormHelperInstanceTag
{
function to_select_radio_tag($select_items, $options)
{
$select_radio = '';
foreach ($select_items as $value => $text){
$select_radio .= parent::to_radio_button_tag($value, $options).
$text.' ';
}
return $select_radio;
}
}
Output html.
< html>
<input name="search[min]" type="radio" value="1" /> 1 minute
<input name="search[min]" type="radio" value="3" /> 3 minute
<input name="search[min]" type="radio" value="5" /> 5 minute
<input name="search[min]" type="radio" value="10" /> 10 minute
<input name="search[min]" type="radio" /> No select <- if select this.
</html>
Result:
echo $this->params['search']['min'] => 'on';
Thank you so much.
1 to 7 of 7