本文整理汇总了PHP中Symfony\Component\Form\FormInterface::getRoot方法的典型用法代码示例。如果您正苦于以下问题:PHP FormInterface::getRoot方法的具体用法?PHP FormInterface::getRoot怎么用?PHP FormInterface::getRoot使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\Form\FormInterface
的用法示例。
在下文中一共展示了FormInterface::getRoot方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: buildView
/**
* {@inheritdoc}
*/
public function buildView(FormView $view, FormInterface $form, array $options)
{
$data = array_key_exists('data', $view->vars) ? $view->vars['data'] : null;
if ($data instanceof UploadedFile && $form->getRoot()->getErrors()) {
$view->vars['data'] = $data = null;
}
$view->vars = array_replace($view->vars, array('type' => 'file', 'value' => ''));
}
示例2: getRoot
/**
* {@inheritdoc}
*/
public function getRoot()
{
return $this->parent ? $this->parent->getRoot() : $this;
}
示例3: getValidationGroups
/**
* Returns the validation groups of the given form.
*
* @param FormInterface $form The form.
*
* @return array The validation groups.
*/
private static function getValidationGroups(FormInterface $form)
{
$root = $form->getRoot();
// Determine the clicked button of the complete form tree
if (!static::$clickedButtons->contains($root)) {
// Only call findClickedButton() once to prevent an exponential
// runtime
// https://github.com/symfony/symfony/issues/8317
static::$clickedButtons->attach($root, self::findClickedButton($root));
}
$button = static::$clickedButtons->offsetGet($root);
if (null !== $button) {
$groups = $button->getConfig()->getOption('validation_groups');
if (null !== $groups) {
return self::resolveValidationGroups($groups, $form);
}
}
do {
$groups = $form->getConfig()->getOption('validation_groups');
if (null !== $groups) {
return self::resolveValidationGroups($groups, $form);
}
$form = $form->getParent();
} while (null !== $form);
return array(Constraint::DEFAULT_GROUP);
}
示例4: getValidationGroups
/**
* Returns the validation groups of the given form.
*
* @param FormInterface $form The form.
*
* @return array The validation groups.
*/
private static function getValidationGroups(FormInterface $form)
{
$button = self::findClickedButton($form->getRoot());
if (null !== $button) {
$groups = $button->getConfig()->getOption('validation_groups');
if (null !== $groups) {
return self::resolveValidationGroups($groups, $form);
}
}
do {
$groups = $form->getConfig()->getOption('validation_groups');
if (null !== $groups) {
return self::resolveValidationGroups($groups, $form);
}
$form = $form->getParent();
} while (null !== $form);
return array(Constraint::DEFAULT_GROUP);
}
示例5: shouldSkipForEmptyUpdate
/**
* Returns if the update should be skipped for empty value.
*
* @param \Symfony\Component\Form\FormInterface $form
* @param mixed $value
* @param string $fieldDefinitionIdentifier
*
* @return boolean
*/
protected function shouldSkipForEmptyUpdate(FormInterface $form, $value, $fieldDefinitionIdentifier)
{
return $value === null && ($form->getRoot()->has("ezforms_skip_empty_update_{$fieldDefinitionIdentifier}") && $form->getRoot()->get("ezforms_skip_empty_update_{$fieldDefinitionIdentifier}")->getData() === "yes");
}
示例6: buildView
/**
* Pass the 'errors_with_fields'-value to the view
*
* @param FormView $view
* @param FormInterface $form
* @param array $options
*/
public function buildView(FormView $view, FormInterface $form, array $options)
{
// set an 'errors_with_fields' variable for the view to the root's option
$view->vars[self::ERRORS_WITH_FIELDS_OPTION] = $form->getRoot()->getConfig()->getOption(self::ERRORS_WITH_FIELDS_OPTION);
}
示例7: buildView
/**
* {@inheritdoc}
*/
public function buildView(FormView $view, FormInterface $form, array $options)
{
$propertyAccessor = PropertyAccess::createPropertyAccessor();
$view->vars['image_filter'] = $options['image_filter'];
$view->vars['image_path'] = $propertyAccessor->getValue($form->getRoot()->getData(), $options['image_property_path']);
}