Skip to content

Commit 4bf91b4

Browse files
committed
Merge branch 'release/initial'
2 parents 6419d29 + cd04581 commit 4bf91b4

File tree

5 files changed

+73
-15
lines changed

5 files changed

+73
-15
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+

bower.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{
2-
"name": "schema",
3-
"version": "0.0.0",
2+
"name": "angular-schema-form",
3+
"version": "0.0.1",
44
"authors": [
5+
"Textalk",
56
"David Jensen <david.lgj@gmail.com>"
67
],
78
"moduleType": [
@@ -14,7 +15,7 @@
1415
"node_modules",
1516
"bower_components",
1617
"test",
17-
"tests"
18+
"coverage"
1819
],
1920
"dependencies": {
2021
"tv4": "~1.0.15"

package.json

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
{
2-
"name": "schema",
3-
"version": "0.0.0",
4-
"description": "",
5-
"main": "index.js",
2+
"name": "angular-schema-form",
3+
"version": "0.0.1",
4+
"description": "Create forms from a JSON schema",
65
"scripts": {
76
"test": "echo \"Error: no test specified\" && exit 1"
87
},
9-
"author": "",
10-
"license": "ISC",
8+
"author": "Textalk",
9+
"license": "MIT",
1110
"devDependencies": {
1211
"karma": "^0.12.0",
1312
"mocha": "^1.18.0",

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)