Skip to content

Commit 2717b76

Browse files
Change default usage for form groups to be in BS3 normal form
Remove the default classes added to the label and input fields. This allows usage in any type of bootstrap form. Applications can simply add the classes via the pfLabelClass and pfInputClass bindings to use in a horizontal form. Added examples of both use cases.
1 parent e3df995 commit 2717b76

File tree

2 files changed

+25
-26
lines changed

2 files changed

+25
-26
lines changed

src/form/examples/form-group.js

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,31 @@
1717
<example module="patternfly.form">
1818
1919
<file name="index.html">
20-
<form class="form-horizontal" ng-controller="FormDemoCtrl">
21-
20+
<div ng-controller="FormDemoCtrl">
2221
<p>Name: {{ item.name }}</p>
2322
<p>Description: {{ item.description }}</p>
24-
<pf-form-group pf-label="Name" required>
25-
<input id="name" name="name"
26-
ng-model="item.name" type="text" required/>
27-
</pf-form-group>
28-
29-
<pf-form-group pf-input-class="col-sm-9" pf-label="Description">
30-
<textarea id="description" name="description" ng-model="item.description">
31-
{{ item.description }}
32-
</textarea>
33-
</pf-form-group>
34-
</form>
23+
<form>
24+
<pf-form-group pf-label="Name" required>
25+
<input id="name" name="name" ng-model="item.name" type="text" required/>
26+
</pf-form-group>
27+
<pf-form-group pf-label="Description">
28+
<textarea id="description" name="description" ng-model="item.description">
29+
{{ item.description }}
30+
</textarea>
31+
</pf-form-group>
32+
</form>
33+
<p>Horizontal Form</p>
34+
<form class="form-horizontal">
35+
<pf-form-group pf-label="Name" required pf-label-class="col-sm-2" pf-input-class="col-sm-5">
36+
<input id="name" name="name" ng-model="item.name" type="text" required/>
37+
</pf-form-group>
38+
<pf-form-group pf-label="Description" pf-label-class="col-sm-2" pf-input-class="col-sm-5">
39+
<textarea id="description" name="description" ng-model="item.description">
40+
{{ item.description }}
41+
</textarea>
42+
</pf-form-group>
43+
</form>
44+
</div>
3545
</file>
3646
3747
<file name="script.js">

src/form/form-group/form-group.component.js

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,8 @@ angular.module('patternfly.form').component('pfFormGroup', {
1919
var ctrl = this;
2020

2121
ctrl.$postLink = function () {
22-
var input;
23-
var type;
24-
25-
if (!ctrl.pfLabelClass) {
26-
ctrl.pfLabelClass = 'col-sm-2';
27-
}
28-
29-
if (!ctrl.pfInputClass) {
30-
ctrl.pfInputClass = 'col-sm-5';
31-
}
32-
33-
input = getInput($element);
34-
type = input.attr('type');
22+
var input = getInput($element);
23+
var type = input.attr('type');
3524

3625
if (['checkbox', 'radio', 'time'].indexOf(type) === -1) {
3726
input.addClass('form-control');

0 commit comments

Comments
 (0)