Skip to content
This repository was archived by the owner on Apr 30, 2018. It is now read-only.

Commit d301c64

Browse files
committed
feat(wrapper): Compability of horizontal form
This commit gives users the ability to add custom classes to labels and the parent div element of fields #89 Not compatible with horizontal forms
1 parent bf39c6f commit d301c64

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,20 @@ NOTE: All of these properties will be under the `templateOptions` property as of
9191
###### Default
9292
>`undefined`
9393
94+
---
95+
##### labelClass (string)
96+
>`labelClass` is used to add classes to labels.
97+
98+
###### Default
99+
>`undefined`
100+
101+
---
102+
##### fieldDivClass (string)
103+
>`fieldDivClass` is used to add classes to the parent div element of the field.
104+
105+
###### Default
106+
>`undefined`
107+
94108
---
95109
##### addonLeft (object)
96110
>`addonLeft` is used to add an add-on on the left of a field. The object accepts three properties: `text` that sets a simple text, `onClick` will add a `cursor:pointer` and an ng-click to the addon (invoked with the options and scope), and `class` that sets classes to the add-on.
@@ -324,3 +338,4 @@ Please see the [CONTRIBUTING Guidelines](CONTRIBUTING.md).
324338

325339
A special thanks to [Nimbly](http://gonimbly.com) for creating/sponsoring angular-formly's development.
326340
Thanks to [Kent C. Dodds](https://github.com/kentcdodds) for his continued support on the project.
341+

src/wrappers/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@ export default ngModule => {
99
apiCheck: check => ({
1010
templateOptions: {
1111
label: check.string.optional,
12+
labelClass: check.string.optional,
1213
required: check.bool.optional,
1314
labelSrOnly: check.bool.optional,
15+
fieldDivClass: check.string.optional
1416
}
1517
})
1618
},

src/wrappers/label.html

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
<div>
2-
<label for="{{id}}" class="control-label {{to.labelSrOnly ? 'sr-only' : ''}}" ng-if="to.label">
2+
<label for="{{id}}" class="control-label {{to.labelSrOnly ? 'sr-only' : ''}} {{to.labelClass || ''}}" ng-if="to.label">
33
{{to.label}}
44
{{to.required ? '*' : ''}}
55
</label>
6-
<formly-transclude></formly-transclude>
6+
<div class="{{to.fieldDivClass || ''}}"
7+
<formly-transclude></formly-transclude>
8+
</div>
79
</div>
10+

0 commit comments

Comments
 (0)