I see some inconsistencies in routing.

when you submit data with post, the data doesn't goes in the route, as you
do.

the route should be:
    pattern:  /data-edit/update/

That's it. And the defaults for the controller should have not default
parameters. (_controller: A10CrmBundle:Update:update, code:97,)

And of course it is a bad practice pass form data on the URL, unless for a
search form (remember it is one field, and search form is meant to be
bookmarkable).

So how do you hadle field data??

In the controller you should:

updateAction()
{


/** 'code' is the name of the field
   $code = $request->request->get('code');
    $code2 = $request->request->get('code2');

etc....


tip:
   $request->request->get() is for POST data
   $request->query->get() is for GET data

Everything else looks ok.

For the defaults parameters, you should:

If ($request->getMethod() == 'POST' )
{
  //retrieve the fields' data as pointed before
}
else{

//call to the update function and pass the defaults parameters
update(param1, param2, param3);

}

Regards!


2011/5/9 Misel Jordanoszki <jordanos...@gmail.com>

> I'm  begginer in Symfony 2. I want update my database's row. I have
> the following query:
>
>        public function getDataUpdate($code, $code2, $shortname, $name)
>                {
>
>                        $query =
> $this->getEntityManager()->createQuery('UPDATE
> A10\CrmBundle\Entity\Crm c SET c.code2= ?1, c.shortname=           ?2,
> c.name = ?3 WHERE c.code = ?1');
>                        $query->setParameter(1, $code2);
>                        $query->setParameter(2, $shortname);
>                        $query->setParameter(3, $name);
>
>                        return $query->getResult();
>                }
>
> And I have got this route:
>
> data_update:
>    pattern:  /data-edit/update/{code}/{code2}/{shortname}/{name}
>    defaults: { _controller: A10CrmBundle:Update:update, code:97,
> code2:97, shortname:97, name:Harmónia Food Kft.}
>    requirements:
>        _method:  POST
>        code: \d+
>        code2: \d+
>
>
> If I want update the 97., it's work. If other, it doesn't work. I get
> the following message: No route found for "POST /data-edit/data-edit/
> update"
>
> Could anyone help me? Or could I Update Entity with other method?
> I hope, it is understandable. Sorry my english.
>
> Thanks
>
> Misel
>
> --
> 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
>

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