how to submit value after selecting radio button in cakephp? -
my view code here...what code controller, plz can explain.
<td><?php $attributes = array(); $options = array($question['question']['opt1']); echo $this->form->radio($i, $options, $attributes);?> </td> <td><?php $attributes = array(); $options = array($question['question']['opt2']); echo $this->form->radio($i, $options, $attributes);?> </td> <td><?php $attributes = array(); $options = array($question['question']['opt3']); echo $this->form->radio($i, $options, $attributes);?> </td> <td><?php $attributes = array(); $options = array($question['question']['opt4']); echo $this->form->radio($i, $options, $attributes);?> </td> </tr> <?php endforeach; ?> <td><?php echo $this->form->end(__('submit'),array('controller'=>'question')); ?></td>
as simple that. in questions controller let's form submitted '/questions/youractionmethodname'
your code should like:
public function youractionmethodname(){ if($this->request->is('post') && !empty($this->request->data)){ $this->question->create(); //to save new record $this->question->save($this->request->data); } } this should create new new record setting database column value of field 'opt1' value selected user. not sure what's case trying solve. should give thought of how things saved database. tell me more on case , edit code match needs.
cakephp
No comments:
Post a Comment