Skip to content

Commit 2bcc74e

Browse files
committed
Merge branch 'release/v0.0.4'
2 parents 731dd46 + f024e97 commit 2bcc74e

25 files changed

+524
-120
lines changed

CHANGELOG

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
v0.0.4
2+
------
3+
* Fieldsets now properly merge schema defaults.
4+
* Directives for "manual" decorator usage.
5+
* Basic support for buttons.
6+
* Basic support for custom validation error messages.

README.md

+34-1
Original file line numberDiff line numberDiff line change
@@ -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+

bower.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "angular-schema-form",
3-
"version": "0.0.3",
3+
"version": "0.0.4",
44
"authors": [
55
"Textalk",
66
"David Jensen <[email protected]>"

dist/bootstrap-decorator.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)