@@ -61,14 +61,15 @@ Schema Form currently supports the following form field types:
61
61
|:--------------|:------------------------|
62
62
| fieldset | a fieldset with legend |
63
63
| section | just a div |
64
- | actions | horizontal button list, can only submit buttons as items |
64
+ | actions | horizontal button list, can only submit and buttons as items |
65
65
| text | input with type text |
66
66
| textarea | a textarea |
67
67
| number | input type number |
68
68
| checkbox | a checkbox |
69
69
| checkboxes | list of checkboxes |
70
70
| select | a select (single value)|
71
71
| submit | a submit button |
72
+ | button | a button |
72
73
73
74
74
75
@@ -171,6 +172,29 @@ General options most field types can handle:
171
172
title: " Street" , // Title of field, taken from schema if available
172
173
notitle: false , // Set to true to hide title
173
174
description: " Street name" , // A description, taken from schema if available
175
+ validationMessage: " Oh noes, please write a proper address" // A custom validation error message
176
+ }
177
+ ` ` `
178
+
179
+ Validation Messages
180
+ -------------------
181
+ Per default all error messages but "Required" comes from the schema validator
182
+ [tv4](https://github.com/geraintluff/tv4), this might or might not work for you.
183
+ If you supply a ´´´validationMessage´´´ proṕerty in the form definition, and if its value is a
184
+ string that will be used instead on any validation error.
185
+
186
+ If you need more fine grained control you can supply an object instead with keys matching the error
187
+ codes of [tv4](https://github.com/geraintluff/tv4). See ` ` ` tv4 .errorCodes ` ` `
188
+
189
+ Ex.
190
+ ` ` ` javascript
191
+ {
192
+ key: " address.street" ,
193
+ validationMessage: {
194
+ tv4 .errorCodes .STRING_LENGTH_SHORT : " Address is too short, man." ,
195
+ " default" : " Just write a proper address, will you?" , // Special catch all error message
196
+ " required" : " I needz an address plz" // Used for required if specified
197
+ }
174
198
}
175
199
` ` `
176
200
@@ -209,7 +233,16 @@ and the value is the title of the option.
209
233
type: " actions" ,
210
234
items: [
211
235
{ type: ' submit' , title: ' Ok' }
236
+ { type: ' button' , title: ' Cancel' , onClick: " cancel()" }
212
237
]
213
238
}
214
239
` ` `
215
240
241
+ *button* can have a ` ` ` onClick` ` ` attribute that either, as in JSON Form, is a function *or* a
242
+ string with an angular expression, as with ng-click.
243
+ [
244
+ { type: 'button', title: 'Ok', onClick: function(){ ... } }
245
+ { type: 'button', title: 'Cancel', onClick: "cancel()" }
246
+ [
247
+ ` ` `
248
+
0 commit comments