本文整理匯總了PHP中Symfony\Component\Form\FormConfigInterface::getType方法的典型用法代碼示例。如果您正苦於以下問題:PHP FormConfigInterface::getType方法的具體用法?PHP FormConfigInterface::getType怎麽用?PHP FormConfigInterface::getType使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Symfony\Component\Form\FormConfigInterface
的用法示例。
在下文中一共展示了FormConfigInterface::getType方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: createView
/**
* {@inheritdoc}
*/
public function createView(FormView $parent = null)
{
if (null === $parent && $this->parent) {
$parent = $this->parent->createView();
}
return $this->config->getType()->createView($this, $parent);
}
示例2: createView
/**
* {@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;
}
示例3: buildForm
/**
* 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']]);
}
}
示例4: createView
/**
* {@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;
}
示例5: getFilterTypeName
/**
* 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();
}
示例6: __construct
/**
* 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();
}
示例7: assignFormTypeValues
/**
* @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;
}
}
}
示例8: assignFormTypeValues
/**
* @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;
}
}
}