Thanks Nicolas,
But it's not nearly as clean (or intuitive) as...
If ($request->hasErrors()) {
foreach($request->getErrorNames() as $error) {
echo "<div class='$error'>" . $request->getError($error) . "</div>";
}
}
On 9 Dec 2008, at 18:36, Nicolas Perriault wrote:
>
> On Tue, Dec 9, 2008 at 6:06 PM, Lee Bolding <[EMAIL PROTECTED]> wrote:
>
>> I raised this a few weeks ago.
>>
>> IMHO, it was a real bad mistake removing that functionality from
>> $request
>
> Even if it's a bit odd, you can use sfRequest::setAttribute() to store
> temporary data and they'll be available in the templates. Even a
> sfForm instance, eg. in a controller:
>
> public function executeFoo(sfRequest $request)
> {
> $this->form = new FooForm();
> // ... POST check, bind, etc.
> if (!$this->form->isValid())
> {
> $request->setAttribute('submittedForm', $this->form);
> }
> }
>
> And within any template, layout or partial:
>
> <?php if (!is_null($f = $sf_request->getAttribute('submittedForm')) &&
> $f->hasGlobalErrors()): ?>
> <h2>Errors have been encountered</h2>
> <ul>
> <?php foreach ($f->getGlobalErrors() as $error): ?>
> <li><?php echo $error->getMessage() ?></li>
> <?php endforeach; ?>
> </ul>
> <?php endif; ?>
>
> You could just store an array of error messages as well if you prefer
> (and this would be a good idea regarding decoupling purpose between
> view and controller).
>
> Hope this helps,
>
> --
> Nicolas Perriault
> http://prendreuncafe.com - http://symfonians.net - http://sensiolabs.com
> Phone: +33 660 92 08 67
>
> >
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"symfony users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en
-~----------~----~----~----~------~----~------~--~---