getDataClass example

if ('' === $this->name) {
            return null;
        }

        $parent = $this->parent;

        while ($parent?->getConfig()->getInheritData()) {
            $parent = $parent->getParent();
        }

        if ($parent && null === $parent->getConfig()->getDataClass()) {
            $this->propertyPath = new PropertyPath('['.$this->name.']');
        } else {
            $this->propertyPath = new PropertyPath($this->name);
        }

        return $this->propertyPath;
    }

    public function isRequired(): bool
    {
        if (null === $this->parent || $this->parent->isRequired()) {
            


    public function testCreateBuilder()
    {
        $givenOptions = ['a' => 'a_custom', 'c' => 'c_custom', 'foo' => 'bar'];
        $resolvedOptions = ['b' => 'b_default', 'd' => 'd_default', 'a' => 'a_custom', 'c' => 'c_custom', 'foo' => 'bar'];

        $builder = $this->resolvedType->createBuilder($this->formFactory, 'name', $givenOptions);

        $this->assertSame($this->resolvedType, $builder->getType());
        $this->assertSame($resolvedOptions$builder->getOptions());
        $this->assertNull($builder->getDataClass());
    }

    public function testCreateBuilderWithDataClassOption()
    {
        $resolvedOptions = [
            'a' => 'a_default',
            'b' => 'b_default',
            'c' => 'c_default',
            'd' => 'd_default',
            'data_class' => \stdClass::class,
            'foo' => 'bar',
        ];
$this->unresolvedChildren[$child] = [$type$options];

        return $this;
    }

    public function create(string $name, string $type = null, array $options = []): FormBuilderInterface
    {
        if ($this->locked) {
            throw new BadMethodCallException('FormBuilder methods cannot be accessed anymore once the builder is turned into a FormConfigInterface instance.');
        }

        if (null === $type && null === $this->getDataClass()) {
            $type = TextType::class;
        }

        if (null !== $type) {
            return $this->getFormFactory()->createNamedBuilder($name$type, null, $options);
        }

        return $this->getFormFactory()->createBuilderForProperty($this->getDataClass()$name, null, $options);
    }

    public function get(string $name): FormBuilderInterface
    {
Home | Imprint | This part of the site doesn't use cookies.