I am having quite a bit of trouble getting client side validation to work. I have these fields once in which the client side val works, and the other where it doesnt work.
I have debugged the yiiActiveForm javascript and have found two differences:
This json item works when validation is ran:
{
"id":"chorusngaserviceorder-selplan",
"name":"selPlan",
"container":".field-chorusngaserviceorder-selplan",
"input":"#chorusngaserviceorder-selplan",
"validate":function (attribute, value, messages, deferred, $form) {
yii.validation.required(value, messages, {"message":"Selected Plan cannot be blank."});
yii.validation.string(value, messages, {
"message":"Selected Plan must be a string.",
"skipOnEmpty":1});
}
}
This one doesn’t work: Obviously because there appears to be a problem with the container arg.
{
"id":"chorusngaserviceorder-whmcs_ticket_id",
"name":"whmcs_ticket_id",
"container":"$(",
"input":"#chorusngaserviceorder-whmcs_ticket_id",
"validate":function (attribute, value, messages, deferred, $form) {
yii.validation.required(value, messages, {
"message":"WHMCS Ticket Id cannot be blank."});
}
}
The rules array is pretty simple:
public function rules()
{
return array_merge([
[['selPlan', 'whmcs_ticket_id'], 'required'],
[['selPlan'], 'string'],
], parent::rules());
}
The only other difference is that this input field which doesnt work exists in a partial. But when I require the partial, I do pass the same activeform.
Any help would be appreciated.