Shaun
Shaun

Reputation: 2311

Symfony Error rendering in template

I have developed a custom login form without using CMD prompt and it does not have any relation with database.

I just want to validate it.I have applied the validators on username as 'name' => new sfValidatorEmail(),.The isValid function in the action working fine but how can i display the errors in Template file.

My Template code look like ,

<?php echo $form ?>

Upvotes: 2

Views: 3899

Answers (3)

MrGlass
MrGlass

Reputation: 9262

echo $form->renderGlobalErrors(); will output any global errors (such as security token errors), but not ones specific to a field (EG "this field is required" or "this field needs to be a 7 digit number"). I believe field specific errors are output when you render the whole form, but you can use echo $form['field']->renderError() to output the error for a specific field.

Upvotes: 3

JamesHalsall
JamesHalsall

Reputation: 13485

To display all errors you could use...

echo $form->renderGlobalErrors();

Upvotes: 0

plandolt
plandolt

Reputation: 1931

You should read trough the chapter Forms for web Designers on the symfony website.

Upvotes: 1

Related Questions