Reputation: 1067
i've a ctp code snippet of a radio button input:
$this->Form->input('something', array(
'type' => 'select',
'multiple' => 'radio',
'options' => array('true' => 'condition 1','false' => 'condition 2'))
);
but i cannot handle correctly into the controller the request data passed.
It returns an array like this: array((int) 0 => 'true')
. So when i try to insert it into the database (I catch it via $this->request->data['Model']['something']
), it returns a database error, 'cause of the array.
How should I handle it correctly?
thanks in advance
Upvotes: 0
Views: 477
Reputation: 8461
Try this
$options = array('true' => 'condition 1', 'false' => 'condition 2');
$attributes = array('legend' => 'something');
echo $this->Form->radio('something', $options, $attributes);
For Check boxes Try this
$options = array('true' => 'condition 1', 'false' => 'condition 2');
echo $this->Form->input('something', array(
'options' => $options ,
'label' => 'something',
'div' => false,
'type' => 'select',
'class' => '',
'multiple' => 'checkbox'
));
Upvotes: 1