public function testBindValidatesData() { $entity = new AnnotatedClass(); $builder = $this->factory->createBuilder('form', $entity); $builder->add('name', 'form'); $form = $builder->getForm(); $this->filter->expects($this->atLeastOnce())->method('filterEntity'); // specific data is irrelevant $form->bind(array()); }
/** * Listens to the Post Bind event and triggers filtering if adequate. * * POST_SUBMIT is fired for every level of the form, from fields to * embedded forms. this method will filter any level that returns an * entity, or will only filter the root entity if 'cascade_filter' * is set to false. * * @param FormEvent $event */ public function onPostSubmit(FormEvent $event) { $form = $event->getForm(); if (!$form->isRoot() && !$this->getRootFormCascadeOption($form)) { return; } $clientData = $form->getData(); if (!is_object($clientData)) { return; } $this->filterService->filterEntity($clientData); }
/** * Listens to the Post Bind event and triggers filtering if adequate. * * @param FilterDataEvent $event */ public function onPostBind($event) { $form = $event->getForm(); if (!$form->isRoot()) { return; } $clientData = $event->getForm()->getData(); if (!is_object($clientData)) { return; } $this->filterService->filterEntity($clientData); }