Ok, now I understand how this widget works..When you create this kind
of widget, it actually creates two fields: autocomplete_my_field (the
field that is showed and where you insert the data (values of the
array elements) and my_field (a hidden field, where the keys are
inserted).

This widget works ok when you insert only an element but when you
insert more than an element the key of the elements are overwritten
(the id of the second element overwrites the id of the the first one,
the id of the third element overwrites the id of the second
one, ....), so you can not retrieve all them. So it's a bug I think..

Javier

On Feb 24, 4:27 pm, Javier Garcia <tirengar...@gmail.com> wrote:
> Hi,
>
> i have this widget :
>
>     $this->widgetSchema['user']  = new sfWidgetFormChoice(array(
>       'choices'          => array(),
>       'renderer_class'   => 'sfWidgetFormJQueryAutocompleter',
>       'renderer_options' => array('url' => 'autocomplete', 'config' =>
> '{ multiple:true }'),
>     ));
>
> And this is the autocomplete function:
>
>   public function executeAutocomplete($request)
>   {
>
>     $this->getResponse()->setContentType('application/json');
>
>     $q = "%" . $request->getParameter('q') . "%";
>
>     $limit = $request->getParameter('limit');
>
>     //Criteria code
>
>     return $this->renderText(json_encode($cli));
>
>   }
>
> that returns this ("Response" tab in Firebug):
>
> {"17":"John","18":"Ann"}   //the numbers are the values in the id
> field.
>
> Then i choose both names in the autocomplete input this way:
>
> [John, Peter]
>
> When i submit the form, the getPostParameters() method returns this:
>
> array
>   'example' =>
>     array
>       'id' => string '' (length=0)
>       '_csrf_token' => string
> '388774046d0f5c8b4a3f114ddb15af7b' (length=32)
>       'user' => string '18' (length=2)
>   'autocomplete_example' =>
>     array
>       'user' => string 'John, Ann, '
>
> So what should i do to retrieve the id's of the users?
>
> sf 1.4.
>
> Javier

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