luiszg23
(Luis)
August 15, 2017, 1:19am
1
Hi, I’m testing the basic example of wbraganca’s Dynamic form, however there seems to be something wrong in my code,
In the controller in create action, when I put
$Valid = Model::validateMultiple ($modelsAddress) && $valid;
It gives me a validation error and is because $modelAddress->customer_id has no value, and makes sense because it is only up to a few lines after I assign it the value.
Can someone help me please?
softark
(Softark)
August 15, 2017, 11:25am
2
The author of the extension describes how to use it with a detailed sample code.
Are you trying to test the sample code as it is? Then it might be a simple typo.
For example, ‘$Valid’ and ‘$valid’ are different things.
luiszg23
(Luis)
August 16, 2017, 1:28am
3
Hello thank you very much. I used the sample code. In the next link you can see the same issue:
However, delete required rule for $custumer->id is bad idea for the ingrity of database.
softark:
The author of the extension describes how to use it with a detailed sample code.
https://github.com/wbraganca/yii2-dynamicform
Are you trying to test the sample code as it is? Then it might be a simple typo.
For example, ‘$Valid’ and ‘$valid’ are different things.
softark
(Softark)
August 16, 2017, 9:57am
4
I see.
No, I don’t think so. Since the end user won’t touch customer_id attribute in the form at all, and you will always set it in the controller, you don’t have to validate it. The validation is for user input.
http://www.yiiframework.com/doc-2.0/guide-input-validation.html