Skip to content

Commit ed56124

Browse files
committed
Merge branch 'master' into devel
2 parents fb2c26a + 0e33fca commit ed56124

File tree

11 files changed

+40
-14
lines changed

11 files changed

+40
-14
lines changed

README.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ Dates and times:
109109
* [notorii:autoform-datetimepicker](https://atmospherejs.com/notorii/autoform-datetimepicker)
110110
* [lukemadera:autoform-pikaday](https://atmospherejs.com/lukemadera/autoform-pikaday)
111111
* [antalakas:autoform-bs-daterangepicker](https://atmospherejs.com/antalakas/autoform-bs-daterangepicker)
112+
* [drewy:autoform-datetimepicker](https://atmospherejs.com/drewy/autoform-datetimepicker)
112113

113114
Selects:
114115

@@ -494,8 +495,12 @@ group, that is, everything related to a single field -- the label, the input,
494495
and the error message -- in one line.
495496

496497
This component accepts the same attributes as `afFieldInput`.
497-
Attributes that are prefixed with `label-` become attributes on the rendered `label` element while
498-
any remaining attributes are forwarded to the `afFieldInput` component. You can also set `label=false` to omit the `label` element or set `label` to a string to use that text as the label text.
498+
Attributes that are prefixed with `formgroup-` become attributes on the `div`
499+
element, which contains the label and the field. Attributes that are prefixed
500+
with `label-` become attributes on the rendered `label` element while any
501+
remaining attributes are forwarded to the `afFieldInput` component. You can
502+
also set `label=false` to omit the `label` element or set `label` to a
503+
string to use that text as the label text.
499504

500505
### afQuickField
501506

components/afFormGroup/afFormGroup.js

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Template.afFormGroup.helpers({
66
},
77
innerContext: function afFormGroupContext() {
88
var c = AutoForm.Utility.getComponentContext(this, 'afFormGroup');
9+
var afFormGroupAtts = formGroupAtts(c.atts);
910
var afFieldLabelAtts = formGroupLabelAtts(c.atts);
1011
var afFieldInputAtts = formGroupInputAtts(c.atts);
1112

@@ -30,6 +31,8 @@ Template.afFormGroup.helpers({
3031

3132
return {
3233
skipLabel: (c.atts.label === false),
34+
afFormGroupClass: c.atts['formgroup-class'],
35+
afFormGroupAtts: afFormGroupAtts,
3336
afFieldLabelAtts: afFieldLabelAtts,
3437
afFieldInputAtts: afFieldInputAtts,
3538
name: c.atts.name,
@@ -43,6 +46,17 @@ Template.afFormGroup.helpers({
4346
* Private
4447
*/
4548

49+
function formGroupAtts(atts) {
50+
// Separate formgroup options from input options; formgroup items begin with 'formgroup-'
51+
var labelAtts = {};
52+
_.each(atts, function autoFormLabelAttsEach(val, key) {
53+
if (key.indexOf('formgroup-') === 0 && key != 'formgroup-class') {
54+
labelAtts[key.substring(10)] = val;
55+
}
56+
});
57+
return labelAtts;
58+
}
59+
4660
function formGroupLabelAtts(atts) {
4761
// Separate label options from input options; label items begin with 'label-'
4862
var labelAtts = {};
@@ -55,11 +69,11 @@ function formGroupLabelAtts(atts) {
5569
}
5670

5771
function formGroupInputAtts(atts) {
58-
// Separate label options from input options; label items begin with 'label-'
72+
// Separate input options from label and formgroup options
5973
// We also don't want the 'label' option
6074
var inputAtts = {};
6175
_.each(atts, function autoFormLabelAttsEach(val, key) {
62-
if (['id-prefix', 'id', 'label'].indexOf(key) === -1 && key.indexOf('label-') !== 0) {
76+
if (['id-prefix', 'id', 'label'].indexOf(key) === -1 && key.indexOf('label-') !== 0 && key.indexOf('formgroup-') !== 0) {
6377
inputAtts[key] = val;
6478
}
6579
});
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
<template name="afObjectField">
2-
{{> Template.dynamic template=getTemplateName data=this}}
2+
{{> Template.dynamic template=getTemplateName data=innerContext}}
33
</template>

components/afObjectField/afObjectField.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,9 @@
33
Template.afObjectField.helpers({
44
getTemplateName: function () {
55
return AutoForm.getTemplateName('afObjectField', this.template, this.name);
6+
},
7+
innerContext: function() {
8+
var c = AutoForm.Utility.getComponentContext(this, 'afObjectField');
9+
return _.extend({}, this, c.atts);
610
}
711
});

templates/bootstrap3-horizontal/components/afFormGroup/afFormGroup.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template name="afFormGroup_bootstrap3-horizontal">
2-
<div class="form-group {{#if afFieldIsInvalid name=this.name}}has-error{{/if}}" data-required={{required}}>
2+
<div class="form-group {{#if afFieldIsInvalid name=this.name}}has-error{{/if}} {{afFormGroupClass}}" data-required={{required}} {{afFormGroupAtts}}>
33
{{#if skipLabel}}
44
{{! We include the empty label as the easiest way to keep proper field alignment}}
55
<label {{afFieldLabelAtts}}></label>

templates/bootstrap3-horizontal/components/afObjectField/afObjectField.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
<div class="form-group {{#if afFieldIsInvalid name=this.name}}has-error{{/if}}">
33
<label {{afFieldLabelAtts}}>{{afFieldLabelText name=this.name}}</label>
44
<div class="{{rightColumnClass}}">
5-
<div class="panel panel-default autoform-padding-fix">
6-
<div class="panel-body">
5+
<div class="panel panel-default autoform-padding-fix {{panelClass}}">
6+
<div class="panel-body {{bodyClass}}">
77
{{> afQuickFields quickFieldsAtts}}
88
</div>
99
</div>

templates/bootstrap3-inline/bootstrap3-inline.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
</template>
1515

1616
<template name="afFormGroup_bootstrap3-inline">
17-
<div class="form-group {{#if afFieldIsInvalid name=this.name}}has-error{{/if}}" data-required={{required}}>
17+
<div class="form-group {{#if afFieldIsInvalid name=this.name}}has-error{{/if}} {{afFormGroupClass}}" data-required={{required}} {{afFormGroupAtts}}>
1818
{{#unless skipLabel}}
1919
<label {{afFieldLabelAtts}}>{{#if this.labelText}}{{this.labelText}}{{else}}{{afFieldLabelText name=this.name}}{{/if}}</label>
2020
{{/unless}}

templates/bootstrap3/components/afFormGroup/afFormGroup.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template name="afFormGroup_bootstrap3">
2-
<div class="form-group {{#if afFieldIsInvalid name=this.name}}has-error{{/if}}" data-required={{required}}>
2+
<div class="form-group {{#if afFieldIsInvalid name=this.name}}has-error{{/if}} {{afFormGroupClass}}" data-required={{required}} {{afFormGroupAtts}}>
33
{{#unless skipLabel}}
44
<label {{bsFieldLabelAtts}}>{{#if this.labelText}}{{this.labelText}}{{else}}{{afFieldLabelText name=this.name}}{{/if}}</label>
55
{{/unless}}

templates/bootstrap3/components/afObjectField/afObjectField.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<template name="afObjectField_bootstrap3">
2-
<div class="panel panel-default">
2+
<div class="panel {{panelClass}}">
33
{{#with afFieldLabelText name=this.name}}
4-
<div class="panel-heading">
4+
<div class="panel-heading {{headingClass}}">
55
<h3 class="panel-title">{{this}}</h3>
66
</div>
77
{{/with}}
8-
<div class="panel-body">
8+
<div class="panel-body {{bodyClass}}">
99
{{#if afFieldIsInvalid name=this.name}}
1010
<span class="help-block">{{{afFieldMessage name=this.name}}}</span>
1111
{{/if}}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
Template.afObjectField_bootstrap3.helpers({
22
quickFieldsAtts: function () {
33
return _.pick(this, 'name', 'id-prefix');
4+
},
5+
panelClass: function() {
6+
return this.panelClass || 'panel-default';
47
}
58
});

0 commit comments

Comments
 (0)