Answer the question
In order to leave comments, you need to log in
Tabular input with related data?
there are 2 tables:
option - id, name
page_option - id, option_id, lang_id,
value
public function getPageOption()
{
return $this->hasOne(PageOption::className(), ['option_id' => 'id']);
}
.. active form begin
foreach ($options as $index => $option) {
echo $form->field($option, "[$index]pageOption[value]")->label($option->name);
}
.. active form end
public function actionUpdate()
{
$options = Options::find()->with('pageOptions')->indexBy('id');
if (Model::loadMultiple($options , \Yii::$app->request->post()) && Model::validateMultiple($options)) {
foreach ($options as $option) {
$setting->save(false);
}
}
return $this->render('index', compact("options"));
}
Model::loadMultiple($options , \Yii::$app->request->post()) - true
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question