Skip to content

Form: Field Type Options Guessing - can't guess maxlength if field already has attr #12444

@EduardTrayan

Description

@EduardTrayan

Hello,

I have a problem with guessing maxlength attribute if field definition has attr option. Please see below:

$builder
            ->add(
                'title',
                null,
                [
                    'attr' =>
                    [
                        'autocomplete' => 'off',
                        'data-display' => true,
                    ],
                ]
            );
.......

/**
     * Title
     *
     * @var string
     *
     * @ORM\Column(type="string", length=255, nullable=false)
     * @Assert\NotNull(groups={})
     * @Assert\Length(max=255, groups={})
     */
    private $title;

In this case I don't see maxlength attribute in html output, but if I declare field like this (without attr option):

$builder
            ->add(
                'title',
                null,
                [
                ]
            );

maxlength attribute appears in html output.

Could you please clarify this behavior.

Thanks in advance

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions