1. Christoffer Niska
  2. yii-bootstrap
  3. Issues
Issue #245 new

Custom validation classes are ignored

Anonymous created an issue

When using a validation error fields in a standard way, for example:

<?php echo($form->error($model, 'login', $validationArray)); ?>

and feeding it with for example such array:

$validationArray = array

turns out that fields like errorCssClass, successCssClass and validatingCssClass are ignored and TbActiveForm always uses default ones instead.

That's for so called manual errors, when user adds error field manually, as in above example. As for automatic errors (error fields added automatically, with each filed), following code:

    $htmlOptions = array
            'style'=>'display: none',

<?php echo($form->textFieldRow($model, 'login', $htmlOptions)); ?>

works fine during client-validation stage, i.e. proper class names are added, so (in this case) fields are not decorated with any class. But after clicking submit, error summary is displayed and fields are again decorated with error class, what suggests, that after submit custom classes are ignored.

Important notice: only fields are decorated with error class. Prepends, appends and lables are not (as they would be, if errorCssClass wouldn't be set to ''). This suggests, that this is a deeper problem.

Notice 'style'=>'display: none', in the code above. It is necessary due to similar bug. Atrribute 'hideErrorMessage'=>TRUE, is successful only at client validation stage, but after submit, it is ignored and error fields (these automattic, i.e. rendered internally by your code) are normally displayed. And thus styling to hide them.

Comments (3)

  1. Log in to comment