Categories
How-To php WebApps

Symfony 1.1 Validation — Gotchas

1. sfValidatorAnd requires a patch to work with Propel.

Get the patch here.

Read the trac ticket for more details.

2. A huge difference between 1.0 and 1.1 in form validation deals with error handling.

1.0 puts the error handling right in the action. In 1.1 you use code in a lib/forms file that looks like this for validation / error handling and corresponds usually to the object being validated. In the example below the code is in lib/forms/AccountForm.class.php

$this->setValidators(array(
    'username' => new sfValidatorString(array('max_length' => 30))
));

3. sfForm::setDefaults doesn’t work quite right with CSRF values.
you’ll need to patch up code based on this google groups post.

The documentation right now for 1.1 isn’t updated. E.G. The chapter on forms for the 1.1 documentation as of 12 August 2008 will lead you down the wrong path.

To keep up to date on what’s going on with symfony, I totally consider doing the following mandatory and not optional:

  • Join the google group, symfony-users
  • Join the irc channel in irc.freenode.net #symfony any time you’ve got a question that needs asking
  • Since the docs might be off, it’s best to just read the source.

Leave a Reply

Your email address will not be published. Required fields are marked *