I think I may be missing something here that should be relatively common. How can I make all form validation errors, including field-bound errors, show up at the top of the form (global)?
+1
A:
Add something like this at the top of your template:
foreach($form->getWidgetSchema()->getPositions() as $widgetName)
{
echo $form[$widgetName]->renderError();
}
bb
2009-06-24 07:29:37
Great idea, thank you!
James Skidmore
2009-06-24 15:45:46
A:
If you're old school like me (before Symfony 1.1), try
<?php if ($sf_request->hasErrors()): ?>
<p>Please correct the following errors and try again:</p>
<ul>
<?php foreach($sf_request->getErrors() as $name => $error): ?>
<li><?php echo $error ?></li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
sjobe
2009-06-24 15:09:46
Should also work for 1.1+, I have not tested it but I see no reason why they would not maintain backward compatibility.
sjobe
2009-06-24 15:10:48
Thanks for the answer, sjobe. Unfortunately that doesn't work for whatever reason in 1.2.
James Skidmore
2009-06-24 15:46:30
+1
A:
In andvance
<ul>
<?php foreach($form->getWidgetSchema()->getPositions() as $widgetName): ?>
<?php if($form[$widgetName]->hasError()): ?>
<li><?php echo $form[$widgetName]->renderLabelName().': '.__($form[$widgetName]->getError()->getMessageFormat()); ?></li>
<?php endif; ?>
<?php endforeach;?>
</ul>
Mailo
2009-11-05 13:02:32