@@ -61,14 +61,15 @@ Schema Form currently supports the following form field types:
6161|:--------------|:------------------------|
6262| fieldset | a fieldset with legend |
6363| 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 |
6565| text | input with type text |
6666| textarea | a textarea |
6767| number | input type number |
6868| checkbox | a checkbox |
6969| checkboxes | list of checkboxes |
7070| select | a select (single value)|
7171| submit | a submit button |
72+ | button | a button |
7273
7374
7475
@@ -171,6 +172,29 @@ General options most field types can handle:
171172 title: " Street" , // Title of field, taken from schema if available
172173 notitle: false , // Set to true to hide title
173174 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+ }
174198}
175199` ` `
176200
@@ -209,7 +233,16 @@ and the value is the title of the option.
209233 type: " actions" ,
210234 items: [
211235 { type: ' submit' , title: ' Ok' }
236+ { type: ' button' , title: ' Cancel' , onClick: " cancel()" }
212237 ]
213238}
214239` ` `
215240
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