Skip to content

Commit 65049cf

Browse files
committed
Merge branch 'feature/readme' into development
2 parents 6419d29 + 433c16f commit 65049cf

File tree

3 files changed

+64
-6
lines changed

3 files changed

+64
-6
lines changed

README.md

Lines changed: 56 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,59 @@
1-
angular-schema-form
1+
Angular Schema Form
22
===================
33

44
Generate forms from a JSON schema, with AngularJS!
5+
6+
Schema Form is a set of AngularJS directives (and a service..) that can create a form directly from a json schema
7+
definition and also validate against that schema. The defaults may be fine for a lot cases, but you can also
8+
customize it, changing order and type of fields.
9+
10+
11+
Schema Form is inspired by the nice [JSON Form](https://github.com/joshfire/jsonform) library and aims to be roughly
12+
compatible with it, especially it's form defintion. What sets Schema Form apart from JSON Form is that Schema Form
13+
aims to be deeply integrated with AngularJS, i.e. to use the standard AngularJS way of handling forms. It also uses
14+
[tv4](https://github.com/geraintluff/tv4) for validation which means its compatible with version 4 of the json schema
15+
standard. Schema Form, as a default, generates bootstrap 3 friendly HTML.
16+
17+
Another thing that sets Schema Form apart is that it, at the moment, doesn't implement half of what JSON Form
18+
does, nor have any documentation! Which of course we hope to remedy soon.
19+
20+
21+
Try out the [example](http://textalk.github.io/angular-schema-form/src/bootstrap-example.html) where you can edit
22+
the schema or the form definition and see what comes out!
23+
24+
25+
Basic Usage
26+
-----------
27+
28+
```html
29+
<form sf-schema="schema" sf-form="form" sf-model="data"></form>
30+
```
31+
32+
```javascript
33+
function FormController($scope) {
34+
$scope.schema = {
35+
type: "object",
36+
properties: {
37+
name: { type: "string", minLength: 2, title: "Name", description: "Name or alias" },
38+
title: {
39+
type: "string",
40+
enum: ['dr','jr','sir','mrs','mr','NaN','dj']
41+
}
42+
};
43+
44+
45+
$scope.form = [
46+
"*",
47+
{
48+
type: "submit",
49+
title: "Save",
50+
}
51+
];
52+
53+
$scope.data = {};
54+
}
55+
```
56+
57+
58+
59+

src/bootstrap-example.html

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,10 @@ <h3>Model</h3>
5656
"title": "Name",
5757
"description": "Gimme yea name lad",
5858
"type": "string",
59-
"maxLength": 3
59+
"minLength": 2
6060
},
61-
"gender": {
62-
"title": "Choose",
61+
"favorite": {
62+
"title": "Favorite",
6363
"type": "string",
6464
"enum": [
6565
"undefined",
@@ -97,7 +97,10 @@ <h3>Model</h3>
9797
}
9898
};
9999

100-
$scope.form = ['*'];
100+
$scope.form = [
101+
'*',
102+
{ type: 'submit', title: 'Do It!'}
103+
];
101104

102105
$scope.decorator = 'bootstrap-decorator';
103106

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
<div class="form-group">
2-
<input type="submit" class="form-control" value="{{form.title}}">
2+
<input type="submit" class="btn btn-primary" value="{{form.title}}">
33
</div>

0 commit comments

Comments
 (0)