<p dir="auto">Such a function is often need i think...could be great to have an Util for this ..?</p>
<p dir="auto">Hello,</p>
<p dir="auto">I have a problem with guessing <code class="notranslate">maxlength</code> attribute if field definition has <code class="notranslate">attr</code> option. Please see below:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="$builder
            -&gt;add(
                'title',
                null,
                [
                    'attr' =&gt;
                    [
                        'autocomplete' =&gt; 'off',
                        'data-display' =&gt; true,
                    ],
                ]
            );
.......

/**
     * Title
     *
     * @var string
     *
     * @ORM\Column(type=&quot;string&quot;, length=255, nullable=false)
     * @Assert\NotNull(groups={})
     * @Assert\Length(max=255, groups={})
     */
    private $title;"><pre class="notranslate"><code class="notranslate">$builder
            -&gt;add(
                'title',
                null,
                [
                    'attr' =&gt;
                    [
                        'autocomplete' =&gt; 'off',
                        'data-display' =&gt; true,
                    ],
                ]
            );
.......

/**
     * Title
     *
     * @var string
     *
     * @ORM\Column(type="string", length=255, nullable=false)
     * @Assert\NotNull(groups={})
     * @Assert\Length(max=255, groups={})
     */
    private $title;
</code></pre></div>
<p dir="auto">In this case I don't see <code class="notranslate">maxlength</code> attribute in html output, but if I declare field like this (without <code class="notranslate">attr</code> option):</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="$builder
            -&gt;add(
                'title',
                null,
                [
                ]
            );"><pre class="notranslate"><code class="notranslate">$builder
            -&gt;add(
                'title',
                null,
                [
                ]
            );
</code></pre></div>
<p dir="auto"><code class="notranslate">maxlength</code> attribute appears in html output.</p>
<p dir="auto">Could you please clarify this behavior.</p>
<p dir="auto">Thanks in advance</p>