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
Simple
You should try this
registerJs('
jQuery("#w0").yiiActiveForm("add",{
"id": "customer-name",
"name": "name",
"container": ".field-customer-name",
"input": "#customer-name",
"error": ".help-block.help-block-error",
"validate": function(attribute, value, messages, deferred, $form) {
yii.validation.required(value, messages, {
"message": "Name be blank bug."
});
yii.validation.string(value, messages, {
"message": "Name must be a string.",
"max": 255,
"tooLong": "Name should contain at most 255 characters.",
"skipOnEmpty": 1
});
}
});
');
?>
Changes
w0 into your form ID
"id": "customer-name" into your input field ID
"container": ".field-customer-name" into input field div container class