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
absolute0:
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
Darwell.J
(Darwell J)
July 21, 2011, 6:28pm
3
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.
Darwell.J
(Darwell J)
July 21, 2011, 6:44pm
5
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?
mdomba
(Maurizio Domba Cerin)
July 22, 2011, 11:39am
7
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