Answer the question
In order to leave comments, you need to log in
How to set up composite forms in Yii2?
I follow the instructions as here https://github.com/ElisDN/yii2-composite-form
class EditForm extends CompositeForm
{
public function __construct(int $moduleID, $config = [])
{
....
$ageModels = ChildrenAges::find()->all();
$this->ages = array_map(function (ChildrenAges $ageModel) {
return new AgeForm($ageModel);
}, $ageModels);
....
}
....
protected function internalForms()
{
return ['ages'];
}
}
if (request()->isPost && $model->load(request()->post()) && $model->validate()) {
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