Skip to content

Commit fe6f53b

Browse files
committed
onChange form option
Takes either a function or an angular expression and works on most types that are actually an input.
1 parent d4ec00a commit fe6f53b

File tree

12 files changed

+87
-15
lines changed

12 files changed

+87
-15
lines changed

README.md

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -178,15 +178,39 @@ General options most field types can handle:
178178
title: "Street", //Title of field, taken from schema if available
179179
notitle: false, //Set to true to hide title
180180
description: "Street name", //A description, taken from schema if available
181-
validationMessage: "Oh noes, please write a proper address" //A custom validation error message
181+
validationMessage: "Oh noes, please write a proper address", //A custom validation error message
182+
onChange: "valueChanged(form.key,modelValue)" //onChange event handler, expression or function
182183
}
183184
```
184185

185-
Validation Messages
186-
-------------------
186+
### onChange
187+
The ```onChange``` option can be used with most fields and its value should be
188+
either an angular expression, as a string, or a function. If its an expression
189+
it will be evaluated in the parent scope of the ```sf-schema``` directive with
190+
the special locals ```modelValue``` and ```form```. If its a function that will
191+
be called with ```modelValue``` and ```form``` as first and second arguments.
192+
193+
ex.
194+
```javascript
195+
$scope.form = [
196+
{
197+
key: "name",
198+
onChange: "updated(modelValue,form)"
199+
},
200+
{
201+
key: "password",
202+
onChange: function(modelValue,form) {
203+
console.log("Password is",modelValue);
204+
}
205+
}
206+
];
207+
```
208+
209+
### Validation Messages
210+
187211
Per default all error messages but "Required" comes from the schema validator
188212
[tv4](https://github.com/geraintluff/tv4), this might or might not work for you.
189-
If you supply a ´´´validationMessage´´´ proṕerty in the form definition, and if its value is a
213+
If you supply a ```validationMessage``` property in the form definition, and if its value is a
190214
string that will be used instead on any validation error.
191215

192216
If you need more fine grained control you can supply an object instead with keys matching the error

dist/bootstrap-decorator.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)