Creates and returns a Form instance from the type of the form.
/** * @param string|\Symfony\Component\Form\FormTypeInterface $type * @param null $data * @param array $options * @param string|null $editionRole * * @return \Symfony\Component\Form\Form */ public function createForm($type, $data = null, array $options = array(), $editionRole = null) { if (!isset($options['disabled']) && !is_null($editionRole)) { $options['disabled'] = !$this->get('security.authorization_checker')->isGranted($editionRole, $data); } return parent::createForm($type, $data, $options); }
public static function getUploadForms(Controller $controller) { $formImage = $controller->createForm(new ImageMediaFormType(), new Image(), array()); // $formMultipleFiles = $controller->createForm ( new ImageMediaMultipleFormType (), array (), array () ); return array($formImage->createView()); return $formMultipleFiles->createView(); }
public static function createNewForm(Controller $controller, Spot $spot) { $infoSpot = new InfoSpot(); $form = $controller->createForm(InfoSpotType::class, $infoSpot, array('action' => $controller->generateUrl('_bo_ajax_spot_add_spot_info', array('id' => $spot->getId())), 'method' => 'POST')); $form->add('Create', SubmitType::class, array('label' => 'Create', 'attr' => array('class' => 'btn btn-default pull-right'))); return $form; }
public function testCreateForm() { $form = $this->getMock('Symfony\\Component\\Form\\FormInterface'); $formFactory = $this->getMock('Symfony\\Component\\Form\\FormFactoryInterface'); $formFactory->expects($this->once())->method('create')->willReturn($form); $container = $this->getMock('Symfony\\Component\\DependencyInjection\\ContainerInterface'); $container->expects($this->at(0))->method('get')->will($this->returnValue($formFactory)); $controller = new Controller(); $controller->setContainer($container); $this->assertEquals($form, $controller->createForm('foo')); }
/** * {@inheritdoc} */ public function createForm($type, $data = null, array $options = array()) { $this->checkCsrf($options); return parent::createForm($type, $data, $options); }
public function createForm($type, $data = null, array $options = array()) { return parent::createForm($type, $data, $options); }
/** * An Ajax function that deletes a media with a specific media ID * @param Request $request * @param unknown_type $mediaId */ public static function getAnnotationForm(Controller $controller) { $formImage = $controller->createForm(new AnnotationFormType(), new Annotation(), array()); return array($formImage->createView()); }
/** * Create form */ public function createForm($type, $data = null, array $options = array()) { $form = parent::createForm($type, $data, $options); $this->getEventDispatcher()->dispatch(FormEvent::CREATE, new GenericEvent($form)); return $form; }