Answer the question
In order to leave comments, you need to log in
How to make validation through yiiActiveForm?
At me on page at loading of model, fields are then dynamically substituted. And so I want to add validation through yiiActiveForm directly. I write like this
jQuery('#product-form').yiiActiveForm('add', {
'id': 'title',
'name': 'title',
'container': '.field-contactform-title',
'input': '#title',
'error': '.help-block.help-block-error',
'validate': function (attribute, value, messages, deferred) {yii.validation.required(value, messages, {\"message\":\"Address cannot be blank.\"});}
})
", \yii\web\View::POS_END);
add: function (attribute) {
var $form = $(this);
attribute = $.extend({value: getValue($form, attribute)}, attributeDefaults, attribute);
$form.data('yiiActiveForm').attributes.push(attribute);
watchAttribute($form, attribute);
},
Answer the question
In order to leave comments, you need to log in
The doc seems to have this
www.yiiframework.com/doc-2.0/guide-input-validatio...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question