Yii Framework Forum: how to store check box value in database for yii2 - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

how to store check box value in database for yii2

#1 User is offline   vishva 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 3
  • Joined: 10-December 15

Posted 10 December 2015 - 04:09 AM

I am new for yii2 .plz help me to solve this problem.
when i select the multiple checkbox values it show the field must be a string

thanks in advance
0

#2 User is offline   ajith 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 170
  • Joined: 20-March 15
  • Location:Kerala,India

Posted 11 December 2015 - 04:19 AM

View Postvishva, on 10 December 2015 - 04:09 AM, said:

I am new for yii2 .plz help me to solve this problem.
when i select the multiple checkbox values it show the field must be a string

thanks in advance


post some code please
0

#3 User is offline   vishva 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 3
  • Joined: 10-December 15

Posted 13 December 2015 - 11:42 PM

it is my _form.php


<?php

use yii\helpers\Html;
use yii\widgets\ActiveForm;

/* @var $this yii\web\View */
/* @var $model app\models\Field */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="field-form">

<?php $form = ActiveForm::begin(); ?>

<?= $form->field($model, 'name')->textInput(['maxlength' => true]) ?>

<?= $form->field($model, 'gender')->textInput(['maxlength' => true]) ?>

<?= $form->field($model, 'state')->textInput(['maxlength' => true]) ?>

<?=$form->field($model, 'skills')->checkboxList(['a' => 'Item A', 'b' => 'Item B', 'c' => 'Item C'])?>




<div class="form-group">
<?= Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
</div>

<?php ActiveForm::end(); ?>

</div>
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users