jeudi 12 juillet 2018

Yii form retrieving checkbox value

I am still quite new to Yii and I'm trying to retrieve checkbox value. Here is my code

View

echo $form->checkBox($model,'seats_id',  array('value'=>$modSeat->id,'id'=>$modSeat->id));

Controller

if (isset($_POST['TicketCustomer']){
    $model->attributes=$_POST['TicketCustomer'];
    $seats_id=$model->seats_id;
    throw new exception($seats_id); // to check value retrieved
}

The value that I received every time would be 0 and when I check page source it produces two checkbox

<input id="yt1" type="hidden" value="0" name="TicketCustomer[seats_id]" />
<input value="1" id="1" name="TicketCustomer[seats_id]" type="checkbox" />

What should I do to retrieve the value from the checkbox?




Aucun commentaire:

Enregistrer un commentaire