in
http://travistidwell.com/presentations/jsonforms
circa 1995 - 2000
Built within static HTML pages.
The rise of backend templating languages
circa 2000 - today
The rise of frameworks
Like Drupal's Form API
/**
* Returns the render array for the form.
*/
function my_module_my_form($form, &$form_state) {
$form['name'] = array(
'#type' => 'fieldset',
'#title' => t('Name'),
'#collapsible' => TRUE,
'#collapsed' => FALSE,
);
$form['name']['first'] = array(
'#type' => 'textfield',
'#title' => t('First name'),
'#required' => TRUE,
'#default_value' => "First name",
'#description' => "Please enter your first name.",
'#size' => 20,
'#maxlength' => 20,
);
$form['name']['last'] = array(
'#type' => 'textfield',
'#title' => t('Last name'),
'#required' => TRUE,
);
$form['year_of_birth'] = array(
'#type' => 'textfield',
'#title' => "Year of birth",
'#description' => 'Format is "YYYY"',
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => 'Submit',
);
return $form;
}
The server still provides the forms.
circa - The future
Applications must be made differently
"Mobile first" is no longer good enough
Forces us to develop websites like web applications.
We now have to build forms the good ol' fashioned way...
and that sucks.
The next generation of webforms.
Uses a JSON schema to define a form.
{
components: [
{
type: 'textfield',
label: 'First Name',
key: 'firstName',
placeholder: 'Enter your first name.',
defaultValue: 'Travis',
validate: {
maxLength: '',
minLength: '',
required:true
}
},
{
type: 'textfield',
label: 'Last Name',
key: 'lastName',
placeholder: 'Enter your last name.',
defaultValue: 'Tidwell',
validate: {
maxLength: '',
minLength: '',
required: true
}
},
{
type: 'button',
label: 'Submit',
key: 'submit',
action: 'submit'
}
]
}
The schema is then rendered dynamically using JavaScript
https://jsfiddle.net/travistidwell/3ox713fo/5/Ok, this is great... but now I have to build that JSON schema, which is a pain.- Everyone
Loads the schema via REST API
https://jsfiddle.net/travistidwell/Lhc2rdoy/1/Data Binding
https://jsfiddle.net/travistidwell/u00fdhop/5/Submission Handling
https://jsfiddle.net/travistidwell/z39b8074/2/
<script src="https://rawgit.com/formio/ngFormio/develop/dist/formio-full.js"></script>
app.module('myApp', ['formio']);
<formio src="'https://examples.form.io/simple'"></formio>
<script src="https://rawgit.com/formio/ngFormio/develop/dist/formio-full.js"></script>
<script src="https://rawgit.com/formio/react-formio/master/dist/build/Formio.min.js"></script>
using