php - How to show form errorSummary() in red? -
i have form:
<?php $form = $this->beginwidget('cactiveform', array( 'id' => 'login-form', 'enableclientvalidation' => true, 'clientoptions' => array( 'validateonsubmit' => true, ), )); $errormsg = $form->errorsummary($usermodel, "", ""); if(!empty($errormsg)) { echo '<div class="alert alert-danger" style="text-align:center; width:800px; margin:auto;">' . $errormsg . '</div>'; echo '<br>'; } $form->labelex($usermodel, 'email'); echo $form->textfield($usermodel, 'email'); $form->error($usermodel, 'email'); ?>
i trying print error message when email invalid, want print using red background bootstrap. problem without errors still shows red bar.
it seems happens because errorsummary()
never null
output:
thats not how things work summary.
the errorsummary()
-function returns content added page.
function makes sure returned div
marked hidden if there no errors.
the reason done summary there front-end validation well. javascript update , hide/show div
when needed.
so should this:
echo $form->errorsummary($usermodel, "", "", array('class' => "alert alert-danger"));
and rid of if(!empty($errormsg)) ...
Comments
Post a Comment