i have a simple form in symfony2 (beta 5), but the post data is never
bound to the form. here are my classes (trimmed for brevity):

/**
 * Represents a User
 *
 * @ORM\Entity
 * @ORM\HasLifecycleCallbacks()
 */
class User
{
    /**
     * @ORM\Id
     * @ORM\Column(type="integer")
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    protected $id;
    /**
     * @ORM\Column(type="string", unique="true", length="150")
     * @Assert\Email()
     */
    protected $email;

    /**
     * @param string $email
     */
    public function setEmail($email)
    {
        $this->email = $email;
    }

    /**
     * @return string $email
     */
    public function getEmail()
    {
        return $this->email;
    }
}

The form builder:

class UserType extends AbstractType
{
    public function buildForm(FormBuilder $builder, array $options)
    {
        $builder->add('email');
    }
}

the action:

public function addAction()
{
    $request = $this->getRequest();

    if ($request->getMethod() == 'POST')
    {
        $user = new User();
        $form = $this->createForm(new UserType(), $user);
        $form->bindRequest($request);
print_r($_POST);        // fine - contains an email address
echo 'email: ';
print_r($user->getEmail());              // always empty
        if ($form->isValid())            // never valid
        {
             // ....

What's wrong with my set-up? This is the second form I've made with
this problem, so I'm obviously doing something wrong.

Thanks

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en

Reply via email to