本文整理汇总了PHP中Service::getFormFactory方法的典型用法代码示例。如果您正苦于以下问题:PHP Service::getFormFactory方法的具体用法?PHP Service::getFormFactory怎么用?PHP Service::getFormFactory使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Service
的用法示例。
在下文中一共展示了Service::getFormFactory方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: create
/**
* {@inheritdoc}
*/
public function create()
{
$builder = \Service::getFormFactory()->createNamedBuilder($this->getName(), 'form', null, $this->getFormOptions());
$form = $this->build($builder)->getForm();
if ($this->editing) {
$this->fill($form, $this->editing);
}
return $form;
}
示例2: getObjectFromParameters
/**
* Find what to pass as an argument on an action
*
* @param ReflectionParameter $modelParameter The model's parameter we want to investigate
* @param ParameterBag $routeParameters The route's parameters
*/
protected function getObjectFromParameters($modelParameter, $routeParameters)
{
$refClass = $modelParameter->getClass();
$paramName = $modelParameter->getName();
if ($refClass !== null && $refClass->isSubclassOf("Model")) {
// Look for the object's ID/slugs in the routeParameters array
$model = $this->findModelInParameters($modelParameter, $routeParameters);
if ($model !== null) {
return $model;
}
}
// $me -> currently logged in user
if ($paramName == "me") {
return self::getMe();
}
if ($refClass === null) {
// No class provived by the method's definition, we don't know
// what we should pass
return null;
}
switch ($refClass->getName()) {
case "Symfony\\Component\\HttpFoundation\\Request":
return $this->getRequest();
case "Symfony\\Component\\HttpFoundation\\Session\\Session":
return $this->getRequest()->getSession();
case "Symfony\\Component\\HttpFoundation\\Session\\Flash\\FlashBag":
return $this->getRequest()->getSession()->getFlashBag();
case "Monolog\\Logger":
return $this->getLogger();
case "Symfony\\Component\\Form\\FormFactory":
return Service::getFormFactory();
}
return null;
}
示例3: create
/**
* {@inheritDoc}
*/
public function create()
{
$builder = \Service::getFormFactory()->createNamedBuilder('confirm_form');
return $builder->add($this->action, 'submit')->add($this->action == 'Yes' ? 'No' : 'Cancel', 'submit')->add('original_url', 'hidden', array('data' => $this->originalUrl))->getForm();
}