Answer the question
In order to leave comments, you need to log in
How to pass multiple values in checkboxes in yii2?
Good day! There are several checkboxes, when I submit the form, only the value of the first button is entered into the database. The rest are lost...
public function actionAddHouse(){
$model = new House();
$realtors = Realtors::find()->asArray()->all();
if($model->load(Yii::$app->request->post())){
if($model->save()){
Yii::$app->session->setFlash('success', 'Дом успешно поставлен на продажу!');
return $this->refresh();
} else {
Yii::$app->session->setFlash('error', 'Ошибка заполнения формы!');
}
}
return $this->render('house', compact('model', 'realtors'));
}
<?php $items = \yii\helpers\ArrayHelper::map($realtors, 'id', 'name') ?>
<?=$form->field($model, 'realtor_id')->checkboxList($items) ?>
Answer the question
In order to leave comments, you need to log in
radio buttons
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question