Example #1
0
 /**
  * Listener for the {@link FormEvents::POST_SUBMIT} event.
  *
  * @param FormEvent $event The event object
  */
 public function postSubmit(FormEvent $event)
 {
     if ($event->getForm()->isRoot()) {
         // Collect the submitted data of each form
         $this->dataCollector->collectSubmittedData($event->getForm());
         // Assemble a form tree
         // This is done again after the view is built, but we need it here as the view is not always created.
         $this->dataCollector->buildPreliminaryFormTree($event->getForm());
     }
 }
 /**
  * Listener for the {@link FormEvents::POST_SUBMIT} event.
  *
  * @param FormEvent $event The event object
  */
 public function postSubmit(FormEvent $event)
 {
     if ($event->getForm()->isRoot()) {
         // Collect the submitted data of each form
         $this->dataCollector->collectSubmittedData($event->getForm());
         // Assemble a form tree
         // This is done again in collectViewVariables(), but that method
         // is not guaranteed to be called (i.e. when no view is created)
         $this->dataCollector->buildPreliminaryFormTree($event->getForm());
     }
 }
 /**
  * {@inheritdoc}
  */
 public function finishView(FormView $view, FormInterface $form, array $options)
 {
     $this->proxiedType->finishView($view, $form, $options);
     // Remember which view belongs to which form instance, so that we can
     // get the collected data for a view when its form instance is not
     // available (e.g. CSRF token)
     $this->dataCollector->associateFormWithView($form, $view);
     // Since the CSRF token is only present in the FormView tree, we also
     // need to check the FormView tree instead of calling isRoot() on the
     // FormInterface tree
     if (null === $view->parent) {
         $this->dataCollector->collectViewVariables($view);
         // Re-assemble data, in case FormView instances were added, for
         // which no FormInterface instances were present (e.g. CSRF token).
         // Since finishView() is called after finishing the views of all
         // children, we can safely assume that information has been
         // collected about the complete form tree.
         $this->dataCollector->buildFinalFormTree($form, $view);
     }
 }