Adding non-entity fields to your Symfony2 forms


use Symfony\Component\Validator\Constraints\True;

// in your buildForm() method:
$builder
->add("firstName", "text")
->add("lastName", "text")
->add("emailAddress", "email")
->add("t_and_c", "checkbox", array(
"mapped" => false,
"constraints" => new True(array(
"message" => "Please accept the Terms and conditions in order to register")
),
)
);


http://www.richsage.co.uk/2011/07/20/adding-non-entity-fields-to-your-symfony2-forms/

Leave a Reply