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>

0 commit comments

Comments
 (0)