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
Copy file name to clipboardExpand all lines: docs/components/form.md
+48-2Lines changed: 48 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -647,7 +647,7 @@ end
647
647
648
648
### Example 4: Multiple input fields of different types
649
649
650
-
Of course, our input core component accepts not only 'text', but very different input types: In this example, we will introduce 'password', 'number', 'email', 'range', 'textarea' types!
650
+
Of course, our input core component accepts not only 'text', but very different input types: In this example, we will introduce 'password', 'number', 'email', 'range' types!
651
651
652
652
On our example page, we define the input fields, together with a `type: X` configuration:
653
653
@@ -662,7 +662,6 @@ class ExamplePage < Matestack::Ui::Page
If we head to `localhost:3000/example`, and fill in the input field with, e.g., *text* and click the submit button, we will get displayed our error message of `seems to be invalid`. Neat!
824
823
824
+
#### Customizing error rendering
825
+
826
+
Error messages are rendered in a span with class 'error' wrapped by another span with class 'errors'. You can customize the error rendering or deactivate it on a per component basis.
827
+
828
+
For the above example the correspoding html looks like:
829
+
```html
830
+
<spanclass="errors">
831
+
<spanclass="error">seems to be invalid</span>
832
+
</span>
833
+
```
834
+
835
+
###### Deactivate default error rendering
836
+
837
+
Passing `errors: false` to a form input, select, textarea etc. will disable the default error rendering.
838
+
839
+
```ruby
840
+
form_input key::foo, type::text, errors:false
841
+
```
842
+
843
+
##### Customizing default rendering
844
+
845
+
You can customize errors by passing `errors` with a hash.
846
+
Customize the error tag by including a `tag` key with a symbol representing a html tag and the error class by including a `class`
0 commit comments