I’m adding fields dynamically to the form via jQuery, depending on what the user enters in other field. The problem is the error messages for each field are not being displayed, though the validation itself is working. This is the code snippet I use to add validation to the new fields, as per the Yii2 cookbok :
function addValidation(){
$("#seriales").children().each(function (index, value){
console.log("Added validation for serial " + index)
$('#componente-hardware-form').yiiActiveForm("add", {
"id": "serial-" + index,
"name": "ComponenteHardware[serial-" + index + "]",
"container": "#serial-" + index + "group",
"input": "#serial-" + index,
"error": "#serial-" + index + "group .help-block",
"validate": function (attribute, value, messages, deferred, \$form) {
yii.validation.required(value, messages, {'message': 'Validation Message Here'});
}
});
});
}
Sorry, not getting your point. As I said, the yii validation is already working with the code snippet from my first post. The only thing I’m missing is to display the error message under each input, as for the default active fields.