From 21f809645d9d6901106531fcd182e027fa7989a2 Mon Sep 17 00:00:00 2001 From: Victor Woeltjen Date: Fri, 28 Nov 2014 14:12:20 -0800 Subject: [PATCH] [Forms] Add Forms example Add example showing the use of generated forms, WTD-530. --- example/forms/bundle.json | 18 +++++ example/forms/res/templates/exampleForm.html | 19 +++++ example/forms/src/ExampleFormController.js | 79 ++++++++++++++++++++ 3 files changed, 116 insertions(+) create mode 100644 example/forms/bundle.json create mode 100644 example/forms/res/templates/exampleForm.html create mode 100644 example/forms/src/ExampleFormController.js diff --git a/example/forms/bundle.json b/example/forms/bundle.json new file mode 100644 index 0000000000..9226e3780d --- /dev/null +++ b/example/forms/bundle.json @@ -0,0 +1,18 @@ +{ + "name": "Declarative Forms example", + "sources": "src", + "extensions": { + "controllers": [ + { + "key": "ExampleFormController", + "implementation": "ExampleFormController.js", + "depends": [ "$scope" ] + } + ], + "routes": [ + { + "templateUrl": "templates/exampleForm.html" + } + ] + } +} \ No newline at end of file diff --git a/example/forms/res/templates/exampleForm.html b/example/forms/res/templates/exampleForm.html new file mode 100644 index 0000000000..70c65f3ab4 --- /dev/null +++ b/example/forms/res/templates/exampleForm.html @@ -0,0 +1,19 @@ +
+ + + + + + +
+
+
+    
+
+    
+
\ No newline at end of file diff --git a/example/forms/src/ExampleFormController.js b/example/forms/src/ExampleFormController.js new file mode 100644 index 0000000000..fd71122085 --- /dev/null +++ b/example/forms/src/ExampleFormController.js @@ -0,0 +1,79 @@ +/*global define*/ + +define( + [], + function () { + "use strict"; + + function ExampleFormController($scope) { + $scope.state = { + + }; + + $scope.form = { + name: "An example form.", + sections: [ + { + name: "First section", + rows: [ + { + name: "Check me", + control: "checkbox", + key: "checkMe" + }, + { + name: "Enter your name", + required: true, + control: "textfield", + key: "yourName" + }, + { + name: "Enter a number", + control: "textfield", + pattern: "^\\d+$", + key: "aNumber" + } + ] + }, + { + name: "Second section", + rows: [ + { + name: "Pick a date", + required: true, + description: "Enter date in form YYYY-DDD", + control: "datetime", + key: "aDate" + }, + { + name: "Choose something", + control: "select", + options: [ + { name: "Hats", value: "hats" }, + { name: "Bats", value: "bats" }, + { name: "Cats", value: "cats" }, + { name: "Mats", value: "mats" } + ], + key: "aChoice" + }, + { + name: "Choose something", + control: "select", + required: true, + options: [ + { name: "Hats", value: "hats" }, + { name: "Bats", value: "bats" }, + { name: "Cats", value: "cats" }, + { name: "Mats", value: "mats" } + ], + key: "aRequiredChoice" + } + ] + } + ] + }; + } + + return ExampleFormController; + } +); \ No newline at end of file