本文整理汇总了PHP中Symfony\Component\Form\FormView::offsetExists方法的典型用法代码示例。如果您正苦于以下问题:PHP FormView::offsetExists方法的具体用法?PHP FormView::offsetExists怎么用?PHP FormView::offsetExists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\Form\FormView
的用法示例。
在下文中一共展示了FormView::offsetExists方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: finishView
public function finishView(FormView $view, FormInterface $form, array $options)
{
/** @var FormView[] $fields */
if ($view->offsetExists('submit_group')) {
$fields = array($view->offsetGet('submit_group'));
$view->offsetUnset('submit_group');
$view->children = $view->children + $fields;
}
parent::finishView($view, $form, $options);
}
示例2: renderFormElement
/**
* render a field element from the FieldDescription
*
*
* @throws InvalidArgumentException
* @param \Sonata\AdminBundle\Admin\FieldDescriptionInterface $fieldDescription
* @param \Sumfony\Component\Form\FormView $formView
* @param mixed $object
* @param array $params
* @return string
*/
public function renderFormElement(FieldDescriptionInterface $fieldDescription, FormView $formView, $object, $params = array())
{
if (!$fieldDescription->getFieldName()) {
return '';
}
if (!$formView->offsetExists($fieldDescription->getFieldName())) {
throw new \RuntimeException(sprintf('No child named %s', $fieldDescription->getFieldName()));
}
$children = $formView->offsetGet($fieldDescription->getFieldName());
if (in_array('hidden', $children->get('types'))) {
return '';
}
// find the correct edit parameter
// edit : standard | inline
// inline : natural | table
$parentFieldDescription = $fieldDescription->getAdmin()->getParentFieldDescription();
if (!$parentFieldDescription) {
$params['edit'] = $fieldDescription->getOption('edit', 'standard');
$params['inline'] = $fieldDescription->getOption('inline', 'natural');
$base_template = sprintf('SonataAdminBundle:CRUD:base_%s_edit_field.html.twig', 'standard');
} else {
$params['edit'] = $parentFieldDescription->getOption('edit', 'standard');
$params['inline'] = $parentFieldDescription->getOption('inline', 'natural');
$base_template = sprintf('SonataAdminBundle:CRUD:base_%s_edit_field.html.twig', $params['edit']);
}
$template = $this->environment->loadTemplate($fieldDescription->getTemplate());
return $this->output($fieldDescription, $template->render(array_merge($params, array('admin' => $fieldDescription->getAdmin(), 'object' => $object, 'field_description' => $fieldDescription, 'value' => $this->getValueFromFieldDescription($object, $fieldDescription, $params), 'field_element' => $children, 'base_template' => $fieldDescription->getOption('base_template', $base_template)))));
}
示例3: finishView
/**
* {@inheritdoc}
*/
public function finishView(FormView $view, FormInterface $form, array $options)
{
$isManualEditGranted = $this->orderAddressSecurityProvider->isManualEditGranted($options['addressType']);
foreach ($view->children as $child) {
$child->vars['disabled'] = !$isManualEditGranted;
$child->vars['required'] = false;
unset($child->vars['attr']['data-validation'], $child->vars['attr']['data-required'], $child->vars['label_attr']['data-required']);
}
if ($view->offsetExists('accountAddress')) {
$view->offsetGet('accountAddress')->vars['disabled'] = false;
}
}
示例4: finishView
/**
* Validate that reward type field exists on form
*
* {@inheritDoc}
*/
public function finishView(Form\FormView $view, Form\FormInterface $form, array $options)
{
if (!$view->offsetExists(self::REWARD_TYPE)) {
throw new \LogicException('No `' . self::REWARD_TYPE . '` field set on form! Be sure to call parent::buildForm() in form class!');
}
}