Added view, doesn't yet submit

This commit is contained in:
David Taylor
2015-08-05 22:08:00 +03:00
committed by Tom Price
parent f99e16f562
commit 7a0746d1a4
12 changed files with 1165 additions and 6 deletions

View File

@@ -0,0 +1,59 @@
{% extends request.is_ajax|yesno:"base_ajax.html,base.html" %}
{% load widget_tweaks %}
{% load static %}
{% block title %}An event checklist{% endblock %}
{% block content %}
<div ng-controller="FormController">
<form sf-schema="schema" sf-form="form" sf-model="model" ng-submit="onSubmit(myForm)"></form>
</div>
{% endblock %}
{% if request.is_ajax %}
{% block footer %}
An AJAX request footer
{% endblock %}
{% endif %}
{% block js %}
<script type="text/javascript" src="{% static "js/angular-schema-form/angular.min.js"%}"></script>
<script type="text/javascript" src="{% static "js/angular-schema-form/angular-sanitize.js"%}"></script>
<script type="text/javascript" src="{% static "js/angular-schema-form/tv4.min.js"%}"></script>
<script type="text/javascript" src="{% static "js/angular-schema-form/ObjectPath.js"%}"></script>
<script type="text/javascript" src="{% static "js/angular-schema-form/schema-form.min.js"%}"></script>
<script type="text/javascript" src="{% static "js/angular-schema-form/bootstrap-decorator.min.js"%}"></script>
<script>
$(document).ready(function () {
angular.module('myModule', ['schemaForm']).controller('FormController', function($scope) {
{% autoescape off %} {# otherwise quotes get replaced with HTML entities #}
$scope.schema = {{ object.schema.schema }};
$scope.form = {{ object.schema.layout }};
$scope.model = {{ object.data }};
{% endautoescape %}
$scope.onSubmit = function(form) {
// First we broadcast an event so all fields validate themselves
$scope.$broadcast('schemaFormValidate');
// Then we check if the form is valid
if (form.valid) {
// ... do whatever you need to do with your data.
console.log()
}
}
});
angular.bootstrap(document, ['myModule']);
});
</script>
{% endblock %}