Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Form] prototype "required" option is inconsistent with the default option #18311

Closed
@sergeyfedotov

Description

@sergeyfedotov

Seems like this issue is related to #15544

class PhotoType extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder->add('title', TextType::class);
    }

    public function configureOptions(OptionsResolver $resolver)
    {
        $resolver->setDefaults([
            'data_class' => Photo::class,
            'required' => false
        ]);
    }
}

Actual result:

<input type="text" id="news_photos___name___title" name="news[photos][__name__][title]" required="required" class="form-control" />

Prototype is rendered with the "required" option. The explanation of this behavior is given in the comment #15544 (comment)

Is it possible to fix it?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions