You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
But instead of the browser's built-in validation UI, validation errors will be rendered using Bootstrap's [Custom Styles](https://getbootstrap.com/docs/5.2/forms/validation/#custom-styles).
8
+
See the [FormElement documentation](https://www.ember-bootstrap.com/api/classes/Components.FormElement.html) for
[Longer description of how to use the addon in apps.]
32
+
Apply the HTML5 validation attributes as needed to your form controls. The form elements [`@controlType`](https://www.ember-bootstrap.com/api/classes/Components.FormElement.html#property_controlType)
33
+
argument will already apply the correct `type` attribute for the rendered `<input>` element. But you can also add
34
+
additional HTML5 attributes like `required`, by applying them as attributes to the form control.
35
+
For this you must use the block form syntax of form elements, so you can apply them to the yielded form `control` (which basically represents the `<input>`),
36
+
and not the parent *element* (a wrapper `<div>`):
37
+
38
+
```hbs
39
+
<BsForm @model={{this.model}} as |form|>
40
+
<form.element @label="Name" @property="name" as |el|>
In this example we have defined a "Name" text field, which is `required` and has a `minlength` of 3, as well as an optional field of type
49
+
`email`. When submitting this form, or when focussing out of a field, the appropriate Bootstrap validation markup will be rendered:
50
+
51
+

52
+
53
+
Note that the error messages are natively provided by the browser itself, given by the form element's [`validationMessage`](https://developer.mozilla.org/en-US/docs/Web/API/Constraint_validation#validationmessage).
0 commit comments