News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Henrik Bjørnskov's Blog:
Symfony2 Using the validator symfony1 style
February 03, 2012 @ 11:15:01

In this quick new post to his blog Henrik Bjørnskov shows how to use the validators in Symfony2 in a more traditional Symfony 1 style for a form.

Two of the more complicated components in Symfony2 is the Form and Validator component. The Validator is created in such a way it "always" need an Domain Object with Constraints associated through metadata. This is explained in detail here. But there is another way. A way that resemble's the symfony1 forms. Where you could specify the validations directly in your form class.

Code is included in the post to show how to load in a few of the validators (like NotBlank, Email and Choice) and how to use them in the settings defined in the "getDefaultOptions" method.

0 comments voice your opinion now!
symfony2 validator form symfony1 options


blog comments powered by Disqus

Similar Posts

IBM developerWorks: Use Ajax with PHP and DB2 9 - Xajax

Rob Allen's Blog: Zend Framework 2 beta 4 released

Hari KT's Blog: Is there a design flaw for the Components or Packages made by Symfony2 and ZF2

Gonzalo Ayuso: Dependency Injection Containers with PHP. When Pimple is not enough.

Fabien Potencier's Blog: Create your own framework... on top of the Symfony2 Components (part 6)


Community Events





Don't see your event here?
Let us know!


podcast symfony series community voicesoftheelephpant update composer install version laravel library introduction release framework language package opinion security interview tool

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework