本文整理汇总了PHP中Symfony\Component\Form\FormBuilder::has方法的典型用法代码示例。如果您正苦于以下问题:PHP FormBuilder::has方法的具体用法?PHP FormBuilder::has怎么用?PHP FormBuilder::has使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\Form\FormBuilder
的用法示例。
在下文中一共展示了FormBuilder::has方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getChildFormBuilder
/**
* @throws \RuntimeException
* @param \Symfony\Component\Form\FormBuilder $formBuider
* @param $elementId
* @return \Symfony\Component\Form\FormBuilder
*/
public function getChildFormBuilder(FormBuilder $formBuider, $elementId)
{
// todo : warning this introduce a bug if the field name = 'field_name',
// add a check to field will always be 'fieldName'
$elements = explode('_', $elementId);
// always remove the first element : form's name
array_shift($elements);
while ($elementName = array_shift($elements)) {
if (!$formBuider->has($elementName)) {
throw new \RuntimeException(sprintf('The element `%s` does not exists', $elementName));
}
$formBuider = $formBuider->get($elementName);
}
return $formBuider;
}
示例2: contentFormClb
protected function contentFormClb($action, \NyroDev\NyroCmsBundle\Model\Content $row, \Symfony\Component\Form\FormBuilder $form)
{
$langs = $this->get('nyrocms')->getLocaleNames($row);
$defaultLocale = $this->get('nyrocms')->getDefaultLocale($row);
unset($langs[$defaultLocale]);
$this->translations = array();
foreach ($row->getTranslations() as $tr) {
if (!isset($this->translations[$tr->getLocale()])) {
$this->translations[$tr->getLocale()] = array();
}
$this->translations[$tr->getLocale()][$tr->getField()] = $tr;
}
/* @var $form \Ivory\OrderedForm\Builder\OrderedFormBuilder */
$propertyAccess = PropertyAccess::createPropertyAccessor();
foreach ($langs as $lg => $lang) {
foreach ($this->contentTranslationFields as $field => $options) {
if ($form->has($field)) {
$type = $options['type'];
unset($options['type']);
$fieldName = 'lang_' . $lg . '_' . $field;
if (isset($options['required']) && $options['required']) {
$options['constraints'] = array(new Constraints\NotBlank());
}
$form->add($fieldName, $type, array_merge($options, array('label' => $this->trans('admin.content.' . $field) . ' ' . strtoupper($lg), 'mapped' => false, 'data' => isset($this->translations[$lg]) && isset($this->translations[$lg][$field]) ? $this->translations[$lg][$field]->getContent() : $propertyAccess->getValue($row, $field), 'position' => array('after' => $field))));
}
}
}
$adminFormEvent = new AdminFormEvent($action, $row, $form);
$this->get('event_dispatcher')->dispatch(AdminFormEvent::UPDATE_CONTENT, $adminFormEvent);
}