/** * {@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' => '')); }
/** * {@inheritdoc} */ public function getRoot() { return $this->parent ? $this->parent->getRoot() : $this; }
/** * 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); }
/** * 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); }
/** * 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"); }
/** * 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); }
/** * {@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']); }