diff --git a/public/docs/_examples/cb-dynamic-form-deprecated/e2e-spec.ts b/public/docs/_examples/cb-dynamic-form-deprecated/e2e-spec.ts
new file mode 100644
index 0000000000..725022d0f1
--- /dev/null
+++ b/public/docs/_examples/cb-dynamic-form-deprecated/e2e-spec.ts
@@ -0,0 +1,27 @@
+///
+'use strict';
+/* tslint:disable:quotemark */
+describe('Dynamic Form Deprecated', function () {
+
+ beforeAll(function () {
+ browser.get('');
+ });
+
+ it('should submit form', function () {
+ let firstNameElement = element.all(by.css('input[id=firstName]')).get(0);
+ expect(firstNameElement.getAttribute('value')).toEqual('Bombasto');
+
+ let emailElement = element.all(by.css('input[id=emailAddress]')).get(0);
+ let email = 'test@test.com';
+ emailElement.sendKeys(email);
+ expect(emailElement.getAttribute('value')).toEqual(email);
+
+ element(by.css('select option[value="solid"]')).click();
+
+ let saveButton = element.all(by.css('button')).get(0);
+ saveButton.click().then(function(){
+ expect(element(by.xpath("//strong[contains(text(),'Saved the following values')]")).isPresent()).toBe(true);
+ });
+ });
+
+});
diff --git a/public/docs/_examples/cb-dynamic-form-deprecated/ts/app/app.component.ts b/public/docs/_examples/cb-dynamic-form-deprecated/ts/app/app.component.ts
new file mode 100644
index 0000000000..e51561770e
--- /dev/null
+++ b/public/docs/_examples/cb-dynamic-form-deprecated/ts/app/app.component.ts
@@ -0,0 +1,24 @@
+// #docregion
+import { Component } from '@angular/core';
+
+import { DynamicFormComponent } from './dynamic-form.component';
+import { QuestionService } from './question.service';
+
+@Component({
+ selector: 'my-app',
+ template: `
+
+
Job Application for Heroes
+
+
+ `,
+ directives: [DynamicFormComponent],
+ providers: [QuestionService]
+})
+export class AppComponent {
+ questions: any[];
+
+ constructor(service: QuestionService) {
+ this.questions = service.getQuestions();
+ }
+}
diff --git a/public/docs/_examples/cb-dynamic-form-deprecated/ts/app/dynamic-form-question.component.html b/public/docs/_examples/cb-dynamic-form-deprecated/ts/app/dynamic-form-question.component.html
new file mode 100644
index 0000000000..ceb2f41177
--- /dev/null
+++ b/public/docs/_examples/cb-dynamic-form-deprecated/ts/app/dynamic-form-question.component.html
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
{{question.label}} is required
+
diff --git a/public/docs/_examples/cb-dynamic-form-deprecated/ts/app/dynamic-form-question.component.ts b/public/docs/_examples/cb-dynamic-form-deprecated/ts/app/dynamic-form-question.component.ts
new file mode 100644
index 0000000000..0593fd523e
--- /dev/null
+++ b/public/docs/_examples/cb-dynamic-form-deprecated/ts/app/dynamic-form-question.component.ts
@@ -0,0 +1,15 @@
+// #docregion
+import { Component, Input } from '@angular/core';
+import { ControlGroup } from '@angular/common';
+
+import { QuestionBase } from './question-base';
+
+@Component({
+ selector: 'df-question',
+ templateUrl: 'app/dynamic-form-question.component.html'
+})
+export class DynamicFormQuestionComponent {
+ @Input() question: QuestionBase;
+ @Input() form: ControlGroup;
+ get isValid() { return this.form.controls[this.question.key].valid; }
+}
diff --git a/public/docs/_examples/cb-dynamic-form-deprecated/ts/app/dynamic-form.component.html b/public/docs/_examples/cb-dynamic-form-deprecated/ts/app/dynamic-form.component.html
new file mode 100644
index 0000000000..e8f14612c9
--- /dev/null
+++ b/public/docs/_examples/cb-dynamic-form-deprecated/ts/app/dynamic-form.component.html
@@ -0,0 +1,17 @@
+
+
+
+
+
+ Saved the following values
{{payLoad}}
+
+
diff --git a/public/docs/_examples/cb-dynamic-form-deprecated/ts/app/dynamic-form.component.ts b/public/docs/_examples/cb-dynamic-form-deprecated/ts/app/dynamic-form.component.ts
new file mode 100644
index 0000000000..5d6eb833ed
--- /dev/null
+++ b/public/docs/_examples/cb-dynamic-form-deprecated/ts/app/dynamic-form.component.ts
@@ -0,0 +1,30 @@
+// #docregion
+import { Component, Input, OnInit } from '@angular/core';
+import { ControlGroup } from '@angular/common';
+
+import { QuestionBase } from './question-base';
+import { QuestionControlService } from './question-control.service';
+import { DynamicFormQuestionComponent } from './dynamic-form-question.component';
+
+@Component({
+ selector: 'dynamic-form',
+ templateUrl: 'app/dynamic-form.component.html',
+ directives: [DynamicFormQuestionComponent],
+ providers: [QuestionControlService]
+})
+export class DynamicFormComponent implements OnInit {
+
+ @Input() questions: QuestionBase[] = [];
+ form: ControlGroup;
+ payLoad = '';
+
+ constructor(private qcs: QuestionControlService) { }
+
+ ngOnInit() {
+ this.form = this.qcs.toControlGroup(this.questions);
+ }
+
+ onSubmit() {
+ this.payLoad = JSON.stringify(this.form.value);
+ }
+}
diff --git a/public/docs/_examples/cb-dynamic-form-deprecated/ts/app/main.ts b/public/docs/_examples/cb-dynamic-form-deprecated/ts/app/main.ts
new file mode 100644
index 0000000000..5a8d9c5044
--- /dev/null
+++ b/public/docs/_examples/cb-dynamic-form-deprecated/ts/app/main.ts
@@ -0,0 +1,6 @@
+import { bootstrap } from '@angular/platform-browser-dynamic';
+
+import { AppComponent } from './app.component';
+
+bootstrap(AppComponent, [])
+ .catch((err: any) => console.error(err));
diff --git a/public/docs/_examples/cb-dynamic-form-deprecated/ts/app/question-base.ts b/public/docs/_examples/cb-dynamic-form-deprecated/ts/app/question-base.ts
new file mode 100644
index 0000000000..2b32b00f2a
--- /dev/null
+++ b/public/docs/_examples/cb-dynamic-form-deprecated/ts/app/question-base.ts
@@ -0,0 +1,25 @@
+// #docregion
+export class QuestionBase{
+ value: T;
+ key: string;
+ label: string;
+ required: boolean;
+ order: number;
+ controlType: string;
+
+ constructor(options: {
+ value?: T,
+ key?: string,
+ label?: string,
+ required?: boolean,
+ order?: number,
+ controlType?: string
+ } = {}) {
+ this.value = options.value;
+ this.key = options.key || '';
+ this.label = options.label || '';
+ this.required = !!options.required;
+ this.order = options.order === undefined ? 1 : options.order;
+ this.controlType = options.controlType || '';
+ }
+}
diff --git a/public/docs/_examples/cb-dynamic-form-deprecated/ts/app/question-control.service.ts b/public/docs/_examples/cb-dynamic-form-deprecated/ts/app/question-control.service.ts
new file mode 100644
index 0000000000..3d56b0c2f6
--- /dev/null
+++ b/public/docs/_examples/cb-dynamic-form-deprecated/ts/app/question-control.service.ts
@@ -0,0 +1,18 @@
+// #docregion
+import { Injectable } from '@angular/core';
+import { FormBuilder, Validators } from '@angular/common';
+import { QuestionBase } from './question-base';
+
+@Injectable()
+export class QuestionControlService {
+ constructor(private fb: FormBuilder) { }
+
+ toControlGroup(questions: QuestionBase[] ) {
+ let group = {};
+
+ questions.forEach(question => {
+ group[question.key] = question.required ? [question.value || '', Validators.required] : [question.value || ''];
+ });
+ return this.fb.group(group);
+ }
+}
diff --git a/public/docs/_examples/cb-dynamic-form-deprecated/ts/app/question-dropdown.ts b/public/docs/_examples/cb-dynamic-form-deprecated/ts/app/question-dropdown.ts
new file mode 100644
index 0000000000..35a9074c74
--- /dev/null
+++ b/public/docs/_examples/cb-dynamic-form-deprecated/ts/app/question-dropdown.ts
@@ -0,0 +1,12 @@
+// #docregion
+import { QuestionBase } from './question-base';
+
+export class DropdownQuestion extends QuestionBase {
+ controlType = 'dropdown';
+ options: {key: string, value: string}[] = [];
+
+ constructor(options: {} = {}) {
+ super(options);
+ this.options = options['options'] || [];
+ }
+}
diff --git a/public/docs/_examples/cb-dynamic-form-deprecated/ts/app/question-textbox.ts b/public/docs/_examples/cb-dynamic-form-deprecated/ts/app/question-textbox.ts
new file mode 100644
index 0000000000..aaa7edf267
--- /dev/null
+++ b/public/docs/_examples/cb-dynamic-form-deprecated/ts/app/question-textbox.ts
@@ -0,0 +1,12 @@
+// #docregion
+import { QuestionBase } from './question-base';
+
+export class TextboxQuestion extends QuestionBase {
+ controlType = 'textbox';
+ type: string;
+
+ constructor(options: {} = {}) {
+ super(options);
+ this.type = options['type'] || '';
+ }
+}
diff --git a/public/docs/_examples/cb-dynamic-form-deprecated/ts/app/question.service.ts b/public/docs/_examples/cb-dynamic-form-deprecated/ts/app/question.service.ts
new file mode 100644
index 0000000000..ee169d0827
--- /dev/null
+++ b/public/docs/_examples/cb-dynamic-form-deprecated/ts/app/question.service.ts
@@ -0,0 +1,47 @@
+// #docregion
+import { Injectable } from '@angular/core';
+
+import { QuestionBase } from './question-base';
+import { TextboxQuestion } from './question-textbox';
+import { DropdownQuestion } from './question-dropdown';
+
+@Injectable()
+export class QuestionService {
+
+ // Todo: get from a remote source of question metadata
+ // Todo: make asynchronous
+ getQuestions() {
+
+ let questions: QuestionBase[] = [
+
+ new DropdownQuestion({
+ key: 'brave',
+ label: 'Bravery Rating',
+ options: [
+ {key: 'solid', value: 'Solid'},
+ {key: 'great', value: 'Great'},
+ {key: 'good', value: 'Good'},
+ {key: 'unproven', value: 'Unproven'}
+ ],
+ order: 3
+ }),
+
+ new TextboxQuestion({
+ key: 'firstName',
+ label: 'First name',
+ value: 'Bombasto',
+ required: true,
+ order: 1
+ }),
+
+ new TextboxQuestion({
+ key: 'emailAddress',
+ label: 'Email',
+ type: 'email',
+ order: 2
+ })
+ ];
+
+ return questions.sort((a, b) => a.order - b.order);
+ }
+}
diff --git a/public/docs/_examples/cb-dynamic-form-deprecated/ts/example-config.json b/public/docs/_examples/cb-dynamic-form-deprecated/ts/example-config.json
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/public/docs/_examples/cb-dynamic-form-deprecated/ts/index.html b/public/docs/_examples/cb-dynamic-form-deprecated/ts/index.html
new file mode 100644
index 0000000000..ec3e1cbbb2
--- /dev/null
+++ b/public/docs/_examples/cb-dynamic-form-deprecated/ts/index.html
@@ -0,0 +1,29 @@
+
+
+
+
+
+ Dynamic Form
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Loading app...
+
+
+
diff --git a/public/docs/_examples/cb-dynamic-form-deprecated/ts/plnkr.json b/public/docs/_examples/cb-dynamic-form-deprecated/ts/plnkr.json
new file mode 100644
index 0000000000..5034d652aa
--- /dev/null
+++ b/public/docs/_examples/cb-dynamic-form-deprecated/ts/plnkr.json
@@ -0,0 +1,9 @@
+{
+ "description": "Dynamic Form Deprecated",
+ "files":[
+ "!**/*.d.ts",
+ "!**/*.js",
+ "!**/*.[1].*"
+ ],
+ "tags":["cookbook"]
+}
diff --git a/public/docs/_examples/cb-dynamic-form-deprecated/ts/sample.css b/public/docs/_examples/cb-dynamic-form-deprecated/ts/sample.css
new file mode 100644
index 0000000000..fe2cc28481
--- /dev/null
+++ b/public/docs/_examples/cb-dynamic-form-deprecated/ts/sample.css
@@ -0,0 +1,7 @@
+.errorMessage{
+ color:red;
+}
+
+.form-row{
+ margin-top: 10px;
+}
\ No newline at end of file
diff --git a/public/docs/_examples/cb-dynamic-form/ts/app/dynamic-form-question.component.html b/public/docs/_examples/cb-dynamic-form/ts/app/dynamic-form-question.component.html
index ceb2f41177..9f1b8cd4a6 100644
--- a/public/docs/_examples/cb-dynamic-form/ts/app/dynamic-form-question.component.html
+++ b/public/docs/_examples/cb-dynamic-form/ts/app/dynamic-form-question.component.html
@@ -1,17 +1,17 @@
-
+
{{question.label}} is required
diff --git a/public/docs/_examples/cb-dynamic-form/ts/app/dynamic-form-question.component.ts b/public/docs/_examples/cb-dynamic-form/ts/app/dynamic-form-question.component.ts
index 0593fd523e..3381d1c444 100644
--- a/public/docs/_examples/cb-dynamic-form/ts/app/dynamic-form-question.component.ts
+++ b/public/docs/_examples/cb-dynamic-form/ts/app/dynamic-form-question.component.ts
@@ -1,15 +1,16 @@
// #docregion
import { Component, Input } from '@angular/core';
-import { ControlGroup } from '@angular/common';
+import { FormGroup, REACTIVE_FORM_DIRECTIVES } from '@angular/forms';
import { QuestionBase } from './question-base';
@Component({
selector: 'df-question',
- templateUrl: 'app/dynamic-form-question.component.html'
+ templateUrl: 'app/dynamic-form-question.component.html',
+ directives: [REACTIVE_FORM_DIRECTIVES]
})
export class DynamicFormQuestionComponent {
@Input() question: QuestionBase;
- @Input() form: ControlGroup;
+ @Input() form: FormGroup;
get isValid() { return this.form.controls[this.question.key].valid; }
}
diff --git a/public/docs/_examples/cb-dynamic-form/ts/app/dynamic-form.component.html b/public/docs/_examples/cb-dynamic-form/ts/app/dynamic-form.component.html
index e8f14612c9..717f09ff71 100644
--- a/public/docs/_examples/cb-dynamic-form/ts/app/dynamic-form.component.html
+++ b/public/docs/_examples/cb-dynamic-form/ts/app/dynamic-form.component.html
@@ -1,6 +1,6 @@