-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
Closed
Description
Complementing #6645.
With this configuration:
<entity name="Acme\DemoBundle\Entity\Product">
<id name="id" column="id" type="integer">
<generator strategy="AUTO" />
</id>
<field name="name" column="name" type="string" />
<field name="presentation" column="presentation" nullable="true" />
<field name="code" column="code" type="string" />
</entity>
<class name="Acme\DemoBundle\Model\Product">
<property name="name">
<constraint name="NotBlank" />
<constraint name="Length">
<option name="min">2</option>
<option name="max">255</option>
</constraint>
</property>
<property name="code">
<constraint name="NotBlank" />
<constraint name="Regex">
<option name="pattern">/^\d+/</option>
</constraint>
<constraint name="Length">
<option name="min">2</option>
<option name="max">255</option>
</constraint>
</property>
</class>
The result is:
<form method="post" novalidate="novalidate">
<div id="product">
<div>
<label for="product_name" class="required">Name</label><input type="text" id="product_name" name="product[name]" required="required"/>
</div>
<div>
<label for="product_presentation" class="required">Presentation</label><input type="text" id="product_presentation" name="product[presentation]" required="required"/>
</div>
<div>
<label for="product_code" class="required">Code</label><input type="text" id="product_code" name="product[code]" required="required"/>
</div>
<input type="hidden" id="product__token" name="product[_token]" value="..."/>
</div>
<button type="submit">Submit</button>
</form>
Expected:
- Name: required=true, minlength=2, maxlength=255
- Presentation: required=false
- Code: required=true, pattern=/^\d+/, minlength=2, maxlength=255
Here is the symfony-standard fork to reproduce the issue:
https://github.com/marcospassos/symfony-standard/tree/master/src/Acme/DemoBundle