Showing validation errors

I have a requirement to not show the error message next to the input fields and just show all errors within the errorSummary. However, if I remove the outputting of $form->error (from underneath the input) then the client side validation doesn’t fire & hence doesn’t show in the errorSummary (server side does).

Does anyone know how I can get around this?

Example code before removal of $form->error:


<?php echo $form->errorSummary($model); ?>


<div class="row">

    <?php echo $form->labelEx($model,'firstName'); ?>

    <?php echo $form->textField($model,'firstName'); ?>

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

</div>

<div class="row">

    <?php echo $form->labelEx($model,'lastName'); ?>

    <?php echo $form->textField($model,'lastName'); ?>

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

</div>

Cheers

Dave

Does anyone know of solution for this please?

Thanks

This would not be the best practice, but if you can’t find another solution - just hide the error fields with CSS.

I was thinking CSS, but was hoping there was a way to handle it using the framework.

It’s strange though, I have the same thing in my project (show only error summary) and it works.

So how are you managing to do this?

I haven’t tried this yet… but the CActiveForm->clientOptions has a property “hideErrorMessage”, that could do what you need…

http://www.yiiframework.com/doc/api/1.1/CActiveForm#clientOptions-detail

Genius! Yep, that does the trick.

Thanks

Dave