Skip to content

Commit d35dca8

Browse files
committed
Names and classes
Added support for fieldHtmlClass and htmlClass form settings, also added name attributes based on the last name of the form key. This way we browsers can autocomplete fields. Threw in some class names as well for good measure schema-form-<form type>
1 parent c9a91a5 commit d35dca8

18 files changed

+68
-45
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<div class="btn-group" ng-transclude></div>
1+
<div class="btn-group schema-form-actions {{form.htmlClass}}" ng-transclude></div>

src/directives/decorators/bootstrap/actions.html

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
<div class="btn-group">
1+
<div class="btn-group schema-form-actions {{form.htmlClass}}">
22
<input ng-repeat-start="item in form.items"
33
type="submit"
4-
class="btn {{ item.style || 'btn-primary' }}"
4+
class="btn {{ item.style || 'btn-default' }} {{form.fieldHtmlClass}}"
55
value="{{item.title}}"
66
ng-if="item.type === 'submit'">
7-
<button ng-repeat-end class="btn {{ item.style || 'btn-default' }}"
7+
<button ng-repeat-end
8+
class="btn {{ item.style || 'btn-default' }} {{form.fieldHtmlClass}}"
89
type="button"
910
ng-disabled="form.readonly"
1011
ng-if="item.type !== 'submit'"

src/directives/decorators/bootstrap/array.html

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
<div sf-array="form" ng-model="$$value$$" ng-model-options="form.ngModelOptions">
1+
<div sf-array="form" class="schema-form-array {{form.htmlClass}}"
2+
ng-model="$$value$$" ng-model-options="form.ngModelOptions">
23
<h3 ng-show="form.title && form.notitle !== true">{{ form.title }}</h3>
34
<ol class="list-group" ng-model="modelArray" ui-sortable>
4-
<li class="list-group-item" ng-repeat="item in modelArray track by $index">
5+
<li class="list-group-item {{form.fieldHtmlClass}}"
6+
ng-repeat="item in modelArray track by $index">
57
<button ng-hide="form.readonly"
68
ng-click="deleteFromArray($index)"
79
style="position: relative; z-index: 20;"
@@ -12,7 +14,7 @@ <h3 ng-show="form.title && form.notitle !== true">{{ form.title }}</h3>
1214
</li>
1315
</ol>
1416
<div class="clearfix" style="padding: 15px;">
15-
<button ng-hide="form.readonly"
17+
<button ng-hide="form.readonly || form.add === null"
1618
ng-click="appendToArray()"
1719
type="button"
1820
class="btn {{ form.style.add || 'btn-default' }} pull-right">

src/directives/decorators/bootstrap/checkbox.html

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
1-
<div class="checkbox" ng-class="{'has-error': hasError(), 'has-success': hasSuccess()}">
1+
<div class="checkbox schema-form-checkbox {{form.htmlClass}}"
2+
ng-class="{'has-error': hasError(), 'has-success': hasSuccess()}">
23
<label>
34
<input type="checkbox"
45
sf-changed="form"
56
ng-disabled="form.readonly"
67
ng-model="$$value$$"
78
ng-model-options="form.ngModelOptions"
8-
schema-validate="form">
9+
schema-validate="form"
10+
class="{{form.fieldHtmlClass}}"
11+
name="{{form.key.slice(-1)[0]}}">
912
<span ng-bind-html="form.title"></span>
1013
</label>
1114

src/directives/decorators/bootstrap/checkboxes.html

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
1-
<div sf-array="form" ng-model="$$value$$" class="form-group" ng-class="{'has-error': hasError(), 'has-success': hasSuccess()}">
1+
<div sf-array="form" ng-model="$$value$$"
2+
class="form-group schema-form-checkboxes {{form.htmlClass}}"
3+
ng-class="{'has-error': hasError(), 'has-success': hasSuccess()}">
24
<label class="control-label" ng-show="showTitle()">{{form.title}}</label>
35
<div class="checkbox" ng-repeat="val in titleMapValues track by $index" >
46
<label>
57
<input type="checkbox"
68
ng-disabled="form.readonly"
79
sf-changed="form"
8-
ng-model="titleMapValues[$index]">
10+
class="{{form.fieldHtmlClass}}"
11+
ng-model="titleMapValues[$index]"
12+
name="{{form.key.slice(-1)[0]}}">
913
<span ng-bind-html="form.titleMap[$index].name"></span>
1014
</label>
1115

src/directives/decorators/bootstrap/default.html

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
1-
<div class="form-group" ng-class="{'has-error': hasError(), 'has-success': hasSuccess(), 'has-feedback': form.feedback !== false }">
1+
<div class="form-group schema-form-{{form.type}} {{form.htmlClass}}"
2+
ng-class="{'has-error': hasError(), 'has-success': hasSuccess(), 'has-feedback': form.feedback !== false }">
23
<label class="control-label" ng-show="showTitle()">{{form.title}}</label>
34

45
<input ng-show="form.key"
56
type="{{form.type}}"
67
step="any"
78
sf-changed="form"
89
placeholder="{{form.placeholder}}"
9-
class="form-control"
10+
class="form-control {{form.fieldHtmlClass}}"
1011
ng-model-options="form.ngModelOptions"
1112
ng-model="$$value$$"
1213
ng-disabled="form.readonly"
13-
schema-validate="form">
14+
schema-validate="form"
15+
name="{{form.key.slice(-1)[0]}}">
1416
<span ng-if="form.feedback !== false"
1517
class="form-control-feedback"
1618
ng-class="evalInScope(form.feedback) || {'glyphicon': true, 'glyphicon-ok': hasSuccess(), 'glyphicon-remove': hasError() }"></span>
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
<fieldset ng-disabled="form.readonly">
1+
<fieldset ng-disabled="form.readonly" class="schema-form-fieldset {{form.htmlClass}}">
22
<legend ng-show="form.title">{{ form.title }}</legend>
33
<div class="help-block" ng-show="form.description" ng-bind-html="form.description"></div>
44
<div ng-transclude></div>
5-
</fieldset>
5+
</fieldset>
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
<fieldset ng-disabled="form.readonly">
1+
<fieldset ng-disabled="form.readonly" class="schema-form-fieldset {{form.htmlClass}}">
22
<legend ng-show="form.title">{{ form.title }}</legend>
33
<div class="help-block" ng-show="form.description" ng-bind-html="form.description"></div>
44
<sf-decorator ng-repeat="item in form.items" form="item"></sf-decorator>
5-
</fieldset>
5+
</fieldset>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<div class="helpvalue" ng-bind-html="form.helpvalue"></div>
1+
<div class="helpvalue schema-form-helpvalue {{form.htmlClass}}" ng-bind-html="form.helpvalue"></div>

src/directives/decorators/bootstrap/radio-buttons.html

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
1-
<div class="form-group" ng-class="{'has-error': hasError(), 'has-success': hasSuccess()}">
1+
<div class="form-group schema-form-radiobuttons {{form.htmlClass}}"
2+
ng-class="{'has-error': hasError(), 'has-success': hasSuccess()}">
23
<div>
34
<label class="control-label" ng-show="showTitle()">{{form.title}}</label>
45
</div>
56
<div class="btn-group">
6-
<label class="btn {{ (item.value === $$value$$) ? form.style.selected || 'btn-primary' : form.style.unselected || 'btn-primary'; }}"
7+
<label class="btn {{ (item.value === $$value$$) ? form.style.selected || 'btn-default' : form.style.unselected || 'btn-default'; }}"
78
ng-class="{ active: item.value === $$value$$ }"
89
ng-repeat="item in form.titleMap">
910
<input type="radio"
11+
class="{{form.fieldHtmlClass}}"
1012
sf-changed="form"
1113
style="display: none;"
1214
ng-disabled="form.readonly"
1315
ng-model="$$value$$"
1416
ng-model-options="form.ngModelOptions"
15-
ng-value="item.value">
17+
ng-value="item.value"
18+
name="{{form.key.slice(-1)[0]}}">
1619
<span ng-bind-html="item.name"></span>
1720
</label>
1821
</div>

src/directives/decorators/bootstrap/radios-inline.html

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
1-
<div class="form-group" ng-class="{'has-error': hasError(), 'has-success': hasSuccess()}">
1+
<div class="form-group schema-form-radios-inline {{form.htmlClass}}"
2+
ng-class="{'has-error': hasError(), 'has-success': hasSuccess()}">
23
<label class="control-label" ng-show="showTitle()">{{form.title}}</label>
34
<div>
45
<label class="radio-inline" ng-repeat="item in form.titleMap" >
56
<input type="radio"
7+
class="{{form.fieldHtmlClass}}"
68
sf-changed="form"
79
ng-disabled="form.readonly"
810
ng-model="$$value$$"
9-
ng-value="item.value">
11+
ng-value="item.value"
12+
name="{{form.key.slice(-1)[0]}}">
1013
<span ng-bind-html="item.name"></span>
1114
</label>
1215
</div>

src/directives/decorators/bootstrap/radios.html

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
1-
<div class="form-group" ng-class="{'has-error': hasError(), 'has-success': hasSuccess()}">
1+
<div class="form-group schema-form-radios {{form.htmlClass}}" ng-class="{'has-error': hasError(), 'has-success': hasSuccess()}">
22
<label class="control-label" ng-show="showTitle()">{{form.title}}</label>
33
<div class="radio" ng-repeat="item in form.titleMap" >
44
<label>
55
<input type="radio"
6+
class="{{form.fieldHtmlClass}}"
67
sf-changed="form"
78
ng-disabled="form.readonly"
89
ng-model="$$value$$"
910
ng-model-options="form.ngModelOptions"
10-
ng-value="item.value">
11+
ng-value="item.value"
12+
name="{{form.key.slice(-1)[0]}}">
1113
<span ng-bind-html="item.name"></span>
1214
</label>
1315
</div>
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1-
<div ng-if="!form.condition || evalExpr(form.condition,{ model: model, 'arrayIndex': arrayIndex })">
1+
<div class="schema-form-section {{form.htmlClass}}"
2+
ng-if="!form.condition || evalExpr(form.condition,{ model: model, 'arrayIndex': arrayIndex })">
23
<sf-decorator ng-repeat="item in form.items" form="item"></sf-decorator>
34
</div>

src/directives/decorators/bootstrap/select.html

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
1-
<div class="form-group" ng-class="{'has-error': hasError(), 'has-success': hasSuccess(), 'has-feedback': form.feedback !== false}">
1+
<div class="form-group {{form.htmlClass}} schema-form-select"
2+
ng-class="{'has-error': hasError(), 'has-success': hasSuccess(), 'has-feedback': form.feedback !== false}">
23
<label class="control-label" ng-show="showTitle()">
34
{{form.title}}
45
</label>
56
<select ng-model="$$value$$"
67
ng-model-options="form.ngModelOptions"
78
ng-disabled="form.readonly"
89
sf-changed="form"
9-
class="form-control"
10+
class="form-control {{form.fieldHtmlClass}}"
1011
schema-validate="form"
11-
ng-options="item.value as item.name for item in form.titleMap">
12+
ng-options="item.value as item.name for item in form.titleMap"
13+
name="{{form.key.slice(-1)[0]}}">
1214
</select>
1315
<div class="help-block"
1416
ng-show="(hasError() && errorMessage(schemaError())) || form.description"
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
<div class="form-group">
1+
<div class="form-group schema-form-submit {{form.htmlClass}}">
22
<input type="submit"
3-
class="btn {{ form.style || 'btn-primary' }}"
3+
class="btn {{ form.style || 'btn-primary' }} {{form.fieldHtmlClass}}"
44
value="{{form.title}}"
55
ng-disabled="form.readonly"
66
ng-if="form.type === 'submit'">
@@ -9,4 +9,4 @@
99
ng-click="buttonClick($event,form)"
1010
ng-disabled="form.readonly"
1111
ng-if="form.type !== 'submit'">{{form.title}}</button>
12-
</div>
12+
</div>

src/directives/decorators/bootstrap/tabarray.html

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11

2-
<div sf-array="form" ng-init="selected = { tab: 0 }" class="clearfix">
2+
<div sf-array="form" ng-init="selected = { tab: 0 }"
3+
class="clearfix schema-form-tabarray schema-form-tabarray-{{form.tabType || 'left'}} {{form.htmlClass}}">
34
<div ng-if="!form.tabType || form.tabType !== 'right'"
45
ng-class="{'col-xs-3': !form.tabType || form.tabType === 'left'}">
56
<ul class="nav nav-tabs"
6-
ng-class="{ 'tabs-left': !form.tabType || form.tabType === 'left'}"
7-
style="margin-bottom: 15px">
7+
ng-class="{ 'tabs-left': !form.tabType || form.tabType === 'left'}">
88
<li ng-repeat="item in modelArray track by $index"
99
ng-click="$event.preventDefault() || (selected.tab = $index)"
1010
ng-class="{active: selected.tab === $index}">
@@ -20,7 +20,7 @@
2020
</div>
2121

2222
<div ng-class="{'col-xs-9': !form.tabType || form.tabType === 'left' || form.tabType === 'right'}">
23-
<div class="tab-content">
23+
<div class="tab-content {{form.fieldHtmlClass}}">
2424
<div class="tab-pane clearfix"
2525
ng-repeat="item in modelArray track by $index"
2626
ng-show="selected.tab === $index"
@@ -40,8 +40,7 @@
4040
</div>
4141

4242
<div ng-if="form.tabType === 'right'" class="col-xs-3">
43-
<ul class="nav nav-tabs tabs-right"
44-
style="margin-bottom: 15px">
43+
<ul class="nav nav-tabs tabs-right">
4544
<li ng-repeat="item in modelArray track by $index"
4645
ng-click="$event.preventDefault() || (selected.tab = $index)"
4746
ng-class="{active: selected.tab === $index}">

src/directives/decorators/bootstrap/tabs.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
<div ng-init="selected = { tab: 0 }">
2-
<ul class="nav nav-tabs" style="margin-bottom: 15px">
1+
<div ng-init="selected = { tab: 0 }" class="schema-form-tabs {{form.htmlClass}}">
2+
<ul class="nav nav-tabs">
33
<li ng-repeat="tab in form.tabs"
44
ng-disabled="form.readonly"
55
ng-click="$event.preventDefault() || (selected.tab = $index)"
@@ -8,7 +8,7 @@
88
</li>
99
</ul>
1010

11-
<div class="tab-content">
11+
<div class="tab-content {{form.fieldHtmlClass}}">
1212
<div class="tab-pane"
1313
ng-disabled="form.readonly"
1414
ng-repeat="tab in form.tabs"
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
<div class="form-group has-feedback" ng-class="{'has-error': hasError(), 'has-success': hasSuccess()}">
1+
<div class="form-group has-feedback {{form.htmlClass}} schema-form-textarea" ng-class="{'has-error': hasError(), 'has-success': hasSuccess()}">
22
<label ng-show="showTitle()">{{form.title}}</label>
3-
<textarea class="form-control"
3+
<textarea class="form-control {{form.fieldHtmlClass}}"
44
sf-changed="form"
55
placeholder="{{form.placeholder}}"
66
ng-disabled="form.readonly"
77
ng-model="$$value$$"
88
ng-model-options="form.ngModelOptions"
9-
schema-validate="form"></textarea>
9+
schema-validate="form"
10+
name="{{form.key.slice(-1)[0]}}"></textarea>
1011
<span class="help-block">{{ (hasError() && errorMessage(schemaError())) || form.description}}</span>
1112
</div>

0 commit comments

Comments
 (0)