i will create insert multiple checkbox, but i dont understand the syntax, i am googling but i dont know. what is wrong? can anyone help me?
i will create checkbox for form add suspect
<tr>
<td valign="top">KWH</td>
<td valign="top"> : </td>
<td><input type="checkbox" name="data[PlnPostpaidSuspect][kwh]" value="RI/450 VA"> RI/450 VA
<input type="checkbox" name="data[PlnPostpaidSuspect][kwh]" value="RI/900 VA"> RI/900 VA
<input type="checkbox" name="data[PlnPostpaidSuspect][kwh]" value="RI/1300 VA"> RI/1300 VA <br/>
<input type="checkbox" name="data[PlnPostpaidSuspect][kwh]" value="RI/2200 VA"> RI/2200 VA
<input type="checkbox" name="data[PlnPostpaidSuspect][kwh]" value="RI/3600 VA"> RI/3600 VA
<input type="checkbox" name="data[PlnPostpaidSuspect][kwh]" value="RI/6600 VA"> RI/6600 VA <br/></td>
</tr>
in the controller
public function add() {
$this->loadModel('Product');
$this->loadModel('User');
if (!empty($this->request->data)) {
$suspect = $this->PlnPostpaidSuspect->save($this->request->data);
if (!empty($suspect)) {
$this->loadModel('Mutation');
$this->loadModel('Transaction');
$this->request->data['Mutation']['inbox_id'] = $this->request->data['PlnPostpaidSuspect']['inbox_id'];
$this->request->data['Transaction']['inbox_id'] = $this->request->data['PlnPostpaidSuspect']['inbox_id'];
$this->request->data['Mutation']['user_id'] = $this->request->data['Transaction']['user_id'];
$this->Mutation->save($this->request->data);
$this->Transaction->save($this->request->data);
$this->Session->setFlash(__('The pln postpaid suspect has been saved'), 'flash/success');
$this->redirect(array('action' => 'index'));
}else{
$this->Session->setFlash(__('The pln postpaid suspect could not be saved'), 'flash/error');
}
}
$products = $this->Product->find('list');
$users = $this->User->find('list',array(
'fields'=>array('User.id','User.username'),
'order'=>array('User.username')
)
);
$this->set(compact('products','users'));
}
Aucun commentaire:
Enregistrer un commentaire