Z
Z
zepy2018-02-16 21:59:11
Yii
zepy, 2018-02-16 21:59:11

How to change the value of the CheckBox that will be sent to the database?

How to make the checkbox value on the page displayed like this:
5a872960da160858463614.png
And the id of this value was passed to the database
Tried to do this

<?php $form = ActiveForm::begin(); ?>
    <?= $form->field($model, 'time_rec')->checkboxList(\yii\helpers\ArrayHelper::map(\app\models\Worktime::find()->all(),'id','time_work'))->label('') ?>

    <div class="form-group">
        <?= Html::submitButton('Save', ['class' => 'btn btn-success']) ?>
    </div>

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

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry, 2018-02-16
@slo_nik

Good evening.
Set a value for label.

<?= $form->field($model, 'time_rec')->checkboxList(***,'id','time_work'))->label(нужное_значение) ?>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question