Symfony2: get post data from PRE_SET_DATA event

I have a form with bound selects, i.a. changing select 1 may update select 2 that may update select 3 and so one.

In order to to give the right “choices” to my selects (only a few should be displayed at loading, another after changing the select. After a POST, the correct choices should also be set), I set an event listener on the PRE_SET_DATA event.

In this listener, I have:

$updatetodate_object = $event->getData();
$form = $event->getForm();

The problem is that my $updatetodate_object isn’t up to date, there are still the values from DB and not the user’s data, after a POST, whereas I need the updated value to build the “choices”.

I also tried:

$form->getData()

which returns me an exception:

A cycle was detected. Listeners to the PRE_SET_DATA event must not call setData().
You should call setData() on the FormEvent object instead.

Any idea?


Download symfony2.get.post.data.from.pre.set.data.event.zip
Direct Link


Download


Download symfony2.get.post.data.from.pre.set.data.event.zip
Mediafire


Download


Download symfony2.get.post.data.from.pre.set.data.event.zip
Sanshare


Download


Download symfony2.get.post.data.from.pre.set.data.event.zip
Turbobit


Download


Download symfony2.get.post.data.from.pre.set.data.event.zip
Filerio


Download

Both comments and pings are currently closed.

Comments are closed.