For the benefit of the list.

>From Chris Wallsmith (thanks):

-----------------------------------------------
Every form starts with a call to setData(null)
https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Form/Form.php#L227

Adding a if (null === $data) return; condition to your listener would
probably fix it.

-----------------------------------------------

That fixes it.

Roger


On May 23, 3:28 pm, Roger Webb <webb.ro...@gmail.com> wrote:
> This worked in beta1 but not in beta2 [seems to be a theme today :
> (  ]   This was Berhard's nifty solution to my AJAX city/state
> problem.
>
> I print_r()'d the array ($realtor_search_params) and it is indeed
> populated with data (an associative array), but I get the following
> exception when I run it:
>
> "Warning: array_key_exists() expects parameter 2 to be array, null
> given ..."
>
> Did something change in the event (or form) system?
>
> From Controller:
>
>         $realtor_search_form = $this->get('form.factory')->create(new
> RealtorSearchType(), $realtor_search_params);
>
> From RealtorSearchType:
>
>         $builder->addEventListener(Events::preSetData, function
> (DataEvent $event) use ($refreshCity) {
>             $data = $event->getData();
>
>             if(array_key_exists('state', $data))  // ERROR IS HERE,
> $data is null
>                 $refreshCity($event->getForm(), $data['state']);
>         });

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