当前位置: 首页>>代码示例>>PHP>>正文


PHP FormBuilder::getName方法代码示例

本文整理汇总了PHP中Symfony\Component\Form\FormBuilder::getName方法的典型用法代码示例。如果您正苦于以下问题:PHP FormBuilder::getName方法的具体用法?PHP FormBuilder::getName怎么用?PHP FormBuilder::getName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Symfony\Component\Form\FormBuilder的用法示例。


在下文中一共展示了FormBuilder::getName方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: buildForm

    public function buildForm(FormBuilder $builder, array $options)
    {
        if (null === $options['property_path']) {
            $options['property_path'] = $builder->getName();
        }

        if (false === $options['property_path'] || '' === $options['property_path']) {
            $options['property_path'] = null;
        } else {
            $options['property_path'] = new PropertyPath($options['property_path']);
        }

        $builder->setRequired($options['required'])
            ->setReadOnly($options['read_only'])
            ->setErrorBubbling($options['error_bubbling'])
            ->setEmptyData($options['empty_data'])
            ->setAttribute('by_reference', $options['by_reference'])
            ->setAttribute('property_path', $options['property_path'])
            ->setAttribute('error_mapping', $options['error_mapping'])
            ->setAttribute('max_length', $options['max_length'])
            ->setAttribute('label', $options['label'] ?: $this->humanize($builder->getName()))
            ->setData($options['data'])
            ->addValidator(new DefaultValidator());

        if ($options['trim']) {
            $builder->addEventSubscriber(new TrimListener());
        }
    }
开发者ID:nacef,项目名称:symfony,代码行数:28,代码来源:FieldType.php

示例2: buildForm

 /**
  * {@inheritdoc}
  */
 public function buildForm(FormBuilder $builder, array $options)
 {
     if (null === $options['property_path']) {
         $options['property_path'] = $builder->getName();
     }
     if (false === $options['property_path'] || '' === $options['property_path']) {
         $options['property_path'] = null;
     } else {
         $options['property_path'] = new PropertyPath($options['property_path']);
     }
     if (!is_array($options['attr'])) {
         throw new FormException('The "attr" option must be "array".');
     }
     $builder->setRequired($options['required'])->setDisabled($options['disabled'])->setErrorBubbling($options['error_bubbling'])->setEmptyData($options['empty_data'])->setAttribute('read_only', $options['read_only'])->setAttribute('by_reference', $options['by_reference'])->setAttribute('property_path', $options['property_path'])->setAttribute('error_mapping', $options['error_mapping'])->setAttribute('max_length', $options['max_length'])->setAttribute('pattern', $options['pattern'])->setAttribute('label', $options['label'] ?: $this->humanize($builder->getName()))->setAttribute('attr', $options['attr'] ?: array())->setAttribute('invalid_message', $options['invalid_message'])->setAttribute('invalid_message_parameters', $options['invalid_message_parameters'])->setAttribute('translation_domain', $options['translation_domain'])->setAttribute('virtual', $options['virtual'])->setData($options['data'])->setDataMapper(new PropertyPathMapper($options['data_class']))->addEventSubscriber(new ValidationListener());
     if ($options['trim']) {
         $builder->addEventSubscriber(new TrimListener());
     }
 }
开发者ID:421p,项目名称:symfony,代码行数:21,代码来源:FormType.php

示例3: add

 /**
  * Adds a new field to this group. A field must have a unique name within
  * the group. Otherwise the existing field is overwritten.
  *
  * If you add a nested group, this group should also be represented in the
  * object hierarchy.
  *
  * @param string|FormBuilder       $child
  * @param string|FormTypeInterface $type
  * @param array                    $options
  *
  * @return FormBuilder The current builder
  */
 public function add($child, $type = null, array $options = array())
 {
     if ($child instanceof self) {
         $this->children[$child->getName()] = $child;
         return $this;
     }
     if (!is_string($child)) {
         throw new UnexpectedTypeException($child, 'string or Symfony\\Component\\Form\\FormBuilder');
     }
     if (null !== $type && !is_string($type) && !$type instanceof FormTypeInterface) {
         throw new UnexpectedTypeException($type, 'string or Symfony\\Component\\Form\\FormTypeInterface');
     }
     if ($this->currentLoadingType && ($type instanceof FormTypeInterface ? $type->getName() : $type) == $this->currentLoadingType) {
         throw new CircularReferenceException(is_string($type) ? $this->getFormFactory()->getType($type) : $type);
     }
     $this->children[$child] = array('type' => $type, 'options' => $options);
     return $this;
 }
开发者ID:hermann106,项目名称:PasaGlProject,代码行数:31,代码来源:FormBuilder.php

示例4: __construct

 /**
  * @param \Symfony\Component\Form\FormBuilder $formBuilder
  * @param bool                                $prefix
  */
 public function __construct(FormBuilder $formBuilder, $prefix = false)
 {
     $this->formBuilder = $formBuilder;
     $this->prefix = $prefix ? $prefix : $formBuilder->getName();
     $this->iterator = new \ArrayIterator(self::getKeys($formBuilder));
 }
开发者ID:LamaDelRay,项目名称:test_symf,代码行数:10,代码来源:FormBuilderIterator.php

示例5: checkFormBuilderDeps

 private function checkFormBuilderDeps(\Symfony\Component\Form\FormBuilder $builder, array &$elements, array &$requirments)
 {
     if ($builder->getCompound()) {
         $type = $builder->getType();
         if ($type instanceof \Symfony\Component\Form\Extension\DataCollector\Proxy\ResolvedTypeDataCollectorProxy) {
             $type = $type->getInnerType();
         }
         if (!$type instanceof \Symfony\Component\Form\Extension\Core\Type\ChoiceType) {
             foreach ($builder->all() as $child) {
                 $this->checkFormBuilderDeps($child, $elements, $requirments);
             }
         }
     }
     $options = $builder->getOptions();
     if (isset($options['sf_form_dynamic'])) {
         foreach ($options['sf_form_dynamic'] as $and) {
             foreach ($and as $_name => $values) {
                 $requirments[$_name] = true;
             }
         }
         $elements[$builder->getName()] = $options['sf_form_dynamic'];
     }
 }
开发者ID:symforce,项目名称:symforce-admin,代码行数:23,代码来源:AdminForm.php


注:本文中的Symfony\Component\Form\FormBuilder::getName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。