In the form there is such group of checkboxes
$form->field($model, 'ingredients')->checkboxList(
ArrayHelper::map($ingredients, 'id', 'name')
)
In html it looks like
<input name="Dish[ingredients][]" value="1" type="checkbox">
<input name="Dish[ingredients][]" value="2" type="checkbox">
How I can get an array of checkboxes values in the actionCreate method of controller?
I trying do it like this
Yii::$app->request->post('Dish[ingredients]', [])
but I get an empty array.
Addition:
Ingredients property is not present in generated model Dish, I'm had added it later by the hand. Dish and Ingredients have a many to many relationship.
How to add ingredients to theDish model correctly?
Now if I do
$model = new Dish();
$model->load(Yii::$app->request->post());
var_dump($model->ingredients);
$model->ingredients is empty array.