本文整理汇总了PHP中Symfony\Bundle\FrameworkBundle\Controller\Controller::createForm方法的典型用法代码示例。如果您正苦于以下问题:PHP Controller::createForm方法的具体用法?PHP Controller::createForm怎么用?PHP Controller::createForm使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Bundle\FrameworkBundle\Controller\Controller
的用法示例。
在下文中一共展示了Controller::createForm方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createForm
/**
* @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);
}
示例2: getUploadForms
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();
}
示例3: createNewForm
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;
}
示例4: testCreateForm
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'));
}
示例5: createForm
/**
* {@inheritdoc}
*/
public function createForm($type, $data = null, array $options = array())
{
$this->checkCsrf($options);
return parent::createForm($type, $data, $options);
}
示例6: createForm
public function createForm($type, $data = null, array $options = array())
{
return parent::createForm($type, $data, $options);
}
示例7: getAnnotationForm
/**
* 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());
}
示例8: createForm
/**
* 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;
}