/** * {@inheritdoc} */ public function createView(FormView $parent = null) { if (null === $parent && $this->parent) { $parent = $this->parent->createView(); } return $this->config->getType()->createView($this, $parent); }
/** * {@inheritdoc} */ public function createView(FormView $parent = null) { if (null === $parent && $this->parent) { $parent = $this->parent->createView(); } $type = $this->config->getType(); $options = $this->config->getOptions(); $view = $type->createView($this, $parent); $type->buildView($view, $this, $options); $type->finishView($view, $this, $options); return $view; }
/** * Buildform function. * * @param FormBuilderInterface $builder the formBuilder * @param array $options the options for this form */ public function buildForm(FormBuilderInterface $builder, array $options) { $entityAlias = $this->entityConfiguration['alias']; $entityIdGetter = $this->entityConfiguration['idGetter']; $fieldOptions = $this->formConfig->getOptions(); $fieldType = $this->formConfig->getType()->getName(); foreach ($this->locales as $locale) { $translatedFieldName = $locale . '_' . $this->fieldName; $entityId = $this->entity->{$entityIdGetter}(); $translationData = $entityId ? $this->entityTranslationProvider->getTranslation($entityAlias, $entityId, $this->fieldName, $locale) : ''; $builder->add($translatedFieldName, $fieldType, ['required' => isset($fieldOptions['required']) ? $this->evaluateRequired($fieldOptions['required'], $locale) : false, 'mapped' => false, 'label' => $fieldOptions['label'], 'data' => $translationData, 'constraints' => $fieldOptions['constraints']]); } }
/** * {@inheritdoc} */ public function createView(FormView $parent = null) { if (null === $parent && $this->parent) { $parent = $this->parent->createView(); } $type = $this->config->getType(); $options = $this->config->getOptions(); // The methods createView(), buildView() and finishView() are called // explicitly here in order to be able to override either of them // in a custom resolved form type. $view = $type->createView($this, $parent); $type->buildView($view, $this, $options); foreach ($this->children as $name => $child) { $view->children[$name] = $child->createView($view); } $type->finishView($view, $this, $options); return $view; }
/** * Get filter type name by form config * * @param FormConfigInterface $config * * @return string * * @deprecated Deprecated since version 2.0, to be removed in 2.1. Use EventDispatcher instead. */ protected function getFilterTypeName(FormConfigInterface $config) { $formType = $config->getType()->getInnerType(); return $config->hasAttribute('apply_filter') && is_string($config->getAttribute('apply_filter')) ? $config->getAttribute('apply_filter') : $formType->getName(); }
/** * Creates an unmodifiable copy of a given configuration. * * @param FormConfigInterface $config The configuration to copy. */ public function __construct(FormConfigInterface $config) { $dispatcher = $config->getEventDispatcher(); if (!$dispatcher instanceof UnmodifiableEventDispatcher) { $dispatcher = new UnmodifiableEventDispatcher($dispatcher); } $this->dispatcher = $dispatcher; $this->name = $config->getName(); $this->propertyPath = $config->getPropertyPath(); $this->mapped = $config->getMapped(); $this->byReference = $config->getByReference(); $this->virtual = $config->getVirtual(); $this->compound = $config->getCompound(); $this->type = $config->getType(); $this->viewTransformers = $config->getViewTransformers(); $this->modelTransformers = $config->getModelTransformers(); $this->dataMapper = $config->getDataMapper(); $this->validators = $config->getValidators(); $this->required = $config->getRequired(); $this->disabled = $config->getDisabled(); $this->errorBubbling = $config->getErrorBubbling(); $this->emptyData = $config->getEmptyData(); $this->attributes = $config->getAttributes(); $this->data = $config->getData(); $this->dataClass = $config->getDataClass(); $this->dataLocked = $config->getDataLocked(); $this->options = $config->getOptions(); }
/** * @param \Smarty_Internal_Template $template * @param FormConfigInterface $formFieldConfig * @param FormView $formFieldView */ protected function assignFormTypeValues($template, $formFieldConfig, $formFieldView) { $formFieldType = $formFieldConfig->getType()->getInnerType(); /* access to choices */ if ($formFieldType instanceof ChoiceType) { $template->assign("choices", $formFieldView->vars['choices']); } /* access to collections */ if ($formFieldType instanceof CollectionType) { if (true === $formFieldConfig->getOption('prototype')) { } else { /* access to choices */ if (isset($formFieldView->vars['choices'])) { $template->assign("choices", $formFieldView->vars['choices']); } } } /* access to date */ if ($formFieldType instanceof DateType || $formFieldType instanceof DateTimeType || $formFieldType instanceof BirthdayType) { if ('choice' === $formFieldConfig->getOption('widget')) { /* access to years */ if ($formFieldConfig->getOption('years')) { $formFieldView->vars['years'] = $formFieldConfig->getOption('years'); $template->assign("years", $formFieldView->vars['years']); } /* access to month */ if ($formFieldConfig->getOption('months')) { $formFieldView->vars['months'] = $formFieldConfig->getOption('months'); $template->assign("months", $formFieldView->vars['months']); } /* access to days */ if ($formFieldConfig->getOption('days')) { $formFieldView->vars['days'] = $formFieldConfig->getOption('days'); $template->assign("days", $formFieldView->vars['days']); } /* access to empty_value */ if ($formFieldConfig->getOption('empty_value')) { $formFieldView->vars['empty_value'] = $formFieldConfig->getOption('empty_value'); $template->assign("empty_value", $formFieldView->vars['empty_value']); } } } /* access to thelia type */ if ($formFieldType instanceof TheliaType) { $template->assign("formType", $formFieldView->vars['type']); switch ($formFieldView->vars['type']) { case "choice": if (!isset($formFieldView->vars['options']['choices']) || !is_array($formFieldView->vars['options']['choices'])) { //throw new } $choices = array(); foreach ($formFieldView->vars['options']['choices'] as $value => $choice) { $choices[] = new ChoiceView($value, $value, $choice); } $template->assign("choices", $choices); break; } } }
/** * @param \Smarty_Internal_Template $template * @param FormConfigInterface $formFieldConfig * @param FormView $formFieldView */ protected function assignFormTypeValues($template, $formFieldConfig, $formFieldView) { $formFieldType = $formFieldConfig->getType()->getInnerType(); /* access to choices */ if ($formFieldType instanceof ChoiceType) { $template->assign("choices", $formFieldView->vars['choices']); } /* access to collections */ if ($formFieldType instanceof CollectionType) { if (true === $formFieldConfig->getOption('prototype')) { } else { /* access to choices */ if (isset($formFieldView->vars['choices'])) { $template->assign("choices", $formFieldView->vars['choices']); } } } /* access to thelia type */ if ($formFieldType instanceof TheliaType) { $template->assign("formType", $formFieldView->vars['type']); switch ($formFieldView->vars['type']) { case "choice": if (!isset($formFieldView->vars['options']['choices']) || !is_array($formFieldView->vars['options']['choices'])) { //throw new } $choices = array(); foreach ($formFieldView->vars['options']['choices'] as $value => $choice) { $choices[] = new ChoiceView($value, $value, $choice); } $template->assign("choices", $choices); break; } } }