YII2 : Add Dynamic form fields and their validations

后端 未结 3 1150
鱼传尺愫
鱼传尺愫 2020-12-17 17:44

I am adding dynamic form fields onChange of dropdown. Both types of fields are coming from different models and go to the database in different tables. I have already define

3条回答
  •  粉色の甜心
    2020-12-17 18:28

    Its been a month so guessing this has been solved but for reference for others like me looking for the same and to save having to step thru the framework to find the answer perhaps try something like:

    ...
    use yii\helpers\Json;
    ...
    
    attributes as $attribute) {
        $attribute = Json::htmlEncode($attribute);
        $this->registerJs("jQuery('form').yiiActiveForm('add', $attribute);");
    } ?>
    
    
    ...
    

    Tested with regards to clientValidation and not with above question so have hacked my solution to hopefully answer above question.

提交回复
热议问题