I've followed the examples in the docs and can't for the life of me
figure out why my simple form is not validating. I'm trying to create
and persist a Tracker();

Any help would be appreciated.

I'm setting up the form with:

    // `new_trackers`   [GET] /trackers/new
    public function newTrackersAction()
    {
        $tracker = new Tracker;
        $form = new Form('tracker', $tracker, $this-
>get('validator'));
        $form->add(new TextField('name'));
        $form->add(new TextareaField('description'));
        return $this->render('SupportBundle:Tracker:newTrackers.twig',
array(
            'form' => $form
        ));
    }

Using a very simple Twig template:

<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html;
charset=utf-8" />
    </head>
    <body>
        {% include "SupportBundle:_partials:header.twig" %}
        {% block body %}{% endblock %}
    </body>
</html>

Then processing the submission with:

    /**
     *  `post_trackers`  [POST] /trackers
     */
    public function postTrackersAction()
    {
        $tracker = new Tracker();
        $form = new Form('tracker', $tracker, $this-
>get('validator'));
        $form->bind($this->get('request')->request->get('tracker'));

        if ('POST' === $this->get('request')->getMethod()) {
            $form->bind($this->get('request')->request-
>get('trackers'));

            if ($form->isValid()) {
                $em = $this->container-
>get('doctrine.orm.entity_manager');
                $em->persist($tracker);
                $em->flush();
                return $this->redirect($this-
>generateUrl('get_trackers'));
            }
        }

        return $this->render('SupportBundle:Tracker:newTrackers.twig',
array(
            'form' => $form
        ));
    }

When I try and validate the form I get the following errors:

* Name must not be blank
* Description must not be blank
* The CSRF token is invalid

All my code is availabe here: 
https://github.com/leevigraham/support.symfony2.bundle/tree/development

-- 
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