The problem is you're trying to access submitted data when it has not be handled yet. Basically, when you are in a builder (buildForm
for the abstract types), you are building your form structure. It has nothing to do with form submission/binding. This is why you get the initial data when you call $builder->getData()
because it only know the initial data at this state.
Knowing that the form component allows you to access the submitted data via events. You can attach a listener to your builder and rely on one of the *_submit
event. The FormEvent class will given you the submitted data with $event->getData()
.
See this doc for more information: http://symfony.com/doc/current/cookbook/form/dynamic_form_modification.html