0

i have a problem with the checkbox field that does not save me the data in the database . In the database I have the ' conditions ' field ( chekbox field ) as boolean . when sending the form I do not save as checked ( 1 ) .

my model Rules

return[
 'condizioniRequired' => ['conditions','required'],
            'condizioniType' => ['conditions','boolean'],];

My view

<?= $form->field($model, 'conditions')->checkbox(array('label'=>'Offerted')); ?>

all other fields are saved.

Saba
  • 115
  • 1
  • 15

1 Answers1

1

You have to do like this :

<?= $form->field($model, 'conditions')->checkBox(['uncheck' => '0', 'checked' => '1'])->label('label'=>'Offerted') ?>

I hope this will help!!.

Rahul Pawar
  • 1,016
  • 1
  • 8
  • 25
  • 1
    = $form->field($model, 'conditions')->checkbox(array('label'=>'Offerted')); ?> will do the same effect,this will post data as '0' when unchecked and '1' as checked.I think OP has got wrong in some other place – Kiran Muralee Sep 17 '16 at 21:10
  • Work! Thank's so much. – Saba Sep 19 '16 at 13:24