formio / ngFormio

JSON powered form rendering library for AngularJS + Form.io.
http://formio.github.io/ngFormio/
MIT License
99 stars 102 forks source link

An Angular.js JSON form renderer for Form.io

This library is meant to be used in conjunction with Form.io to provide dynamic JSON form rendering capabilities. This allows you to render any form using the schemas provided by Form.io in the following format.

<formio src="https://github.com/formio/ngFormio/raw/master/'https://myapp.form.io/myform'"></formio>

The following snippit of code will dynamically render the form within Form.io, as well as automatically hook that form up to the REST API generated from the same schema.

Here is a Demo

http://codepen.io/travist/full/xVyMjo/

Multi-page Forms

This renderer also supports multi-page forms using the formio-wizard directive like so.

<formio-wizard src="https://github.com/formio/ngFormio/raw/master/'https://myapp.form.io/mywizard'"></formio-wizard>

This directive uses Panels within the root of the form to indicate new pages within the form.

Installation

There are several ways to add this library to your application. Each of these installation types are for specific use cases.

Full Installation

<link rel="stylesheet" href="https://rawgit.com/formio/ngFormio/master/dist/formio-full.min.css" />
<script src="https://rawgit.com/formio/ngFormio/master/dist/formio-full.min.js"></script>

Complete Installation

<link rel="stylesheet" href="https://rawgit.com/formio/ngFormio/master/dist/formio-complete.min.css" />
<script src="https://rawgit.com/formio/ngFormio/master/dist/formio-complete.min.js"></script>

Basic Installation: (Bower Installation)

bower install --save ng-formio

Then, you can add the following to your application.

<html>
<head>
  <!-- bower:css -->
  <!-- endbower -->
</head>
<body>
  <!-- bower:js -->
  <!-- endbower -->
</body>
</html>

Then run Wiredep to wire it up.

$ node
> require('wiredep')({ src: 'index.html' });

We also recommend using this within a Gulp build process using Wiredep in combination with Gulp UseRef.

Configuration

Once you have this installed, you will now need to add this module within your Angular.js application declaration like so...

app.js

angular.module('yourApp', [
  'formio'
])

Usage

Now that you have the library installed, you can then do the following to add a form to your application.

This not only renders the form dyanmically within your application, but also automatically hooks up that form to the API backend that is provided from Form.io.

Enjoy!

The Form.io Team!