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


PHP FormBuilder::setParent方法代码示例

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


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

示例1: createBuilder

 /**
  * {@inheritdoc}
  */
 public function createBuilder(FormFactoryInterface $factory, $name, array $options = array(), FormBuilderInterface $parent = null)
 {
     $options = $this->getOptionsResolver()->resolve($options);
     // Should be decoupled from the specific option at some point
     $dataClass = isset($options['data_class']) ? $options['data_class'] : null;
     $builder = new FormBuilder($name, $dataClass, new EventDispatcher(), $factory, $options);
     $builder->setType($this);
     $builder->setParent($parent);
     $this->buildForm($builder, $options);
     return $builder;
 }
开发者ID:joan16v,项目名称:symfony2_test,代码行数:14,代码来源:ResolvedFormType.php

示例2: testGetFormConfigErasesReferences

 public function testGetFormConfigErasesReferences()
 {
     $builder = new FormBuilder('name', null, $this->dispatcher, $this->factory);
     $builder->setParent(new FormBuilder('parent', null, $this->dispatcher, $this->factory));
     $builder->add(new FormBuilder('child', null, $this->dispatcher, $this->factory));
     $config = $builder->getFormConfig();
     $reflClass = new \ReflectionClass($config);
     $factory = $reflClass->getProperty('factory');
     $parent = $reflClass->getProperty('parent');
     $children = $reflClass->getProperty('children');
     $unresolvedChildren = $reflClass->getProperty('unresolvedChildren');
     $factory->setAccessible(true);
     $parent->setAccessible(true);
     $children->setAccessible(true);
     $unresolvedChildren->setAccessible(true);
     $this->assertNull($factory->getValue($config));
     $this->assertNull($parent->getValue($config));
     $this->assertEmpty($children->getValue($config));
     $this->assertEmpty($unresolvedChildren->getValue($config));
 }
开发者ID:joan16v,项目名称:symfony2_test,代码行数:20,代码来源:FormBuilderTest.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) {
         $child->setParent($this);
         $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:nashadalam,项目名称:symfony,代码行数:32,代码来源:FormBuilder.php


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