Skip to content

Commit 6bc95b8

Browse files
committed
fix #474 bootstrap-radios values
1 parent 2d11284 commit 6bc95b8

File tree

4 files changed

+28
-22
lines changed

4 files changed

+28
-22
lines changed
Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
<template name="afBooleanRadioGroup">
2-
<div>
3-
<label><input type="radio" value="false" name="{{this.name}}" {{falseAtts}} /> {{#with this.atts.falseLabel}}{{this}}{{else}}False{{/with}}</label>
4-
</div>
5-
<div>
6-
<label><input type="radio" value="true" name="{{this.name}}" {{trueAtts}} /> {{#with this.atts.trueLabel}}{{this}}{{else}}True{{/with}}</label>
2+
<div {{dsk}}>
3+
<div>
4+
<label><input type="radio" value="false" name="{{this.name}}" {{falseAtts}} /> {{#with this.atts.falseLabel}}{{this}}{{else}}False{{/with}}</label>
5+
</div>
6+
<div>
7+
<label><input type="radio" value="true" name="{{this.name}}" {{trueAtts}} /> {{#with this.atts.trueLabel}}{{this}}{{else}}True{{/with}}</label>
8+
</div>
79
</div>
810
</template>

inputTypes/boolean-radios/boolean-radios.js

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
AutoForm.addInputType("boolean-radios", {
22
template: "afBooleanRadioGroup",
33
valueOut: function () {
4-
var val = this.val();
5-
if (this.is(":checked")) {
6-
if (val === "true") {
7-
return true;
8-
} else if (val === "false") {
9-
return false;
10-
}
4+
if (this.find('input[value=false]').is(":checked")) {
5+
return false;
6+
} else if (this.find('input[value=true]').is(":checked")) {
7+
return true;
118
}
129
},
1310
valueConverters: {
@@ -48,18 +45,20 @@ AutoForm.addInputType("boolean-radios", {
4845

4946
Template["afBooleanRadioGroup"].helpers({
5047
falseAtts: function falseAtts() {
51-
var atts = _.omit(this.atts, 'trueLabel', 'falseLabel');
48+
var atts = _.omit(this.atts, 'trueLabel', 'falseLabel', 'data-schema-key');
5249
if (this.value === false) {
5350
atts.checked = "";
5451
}
5552
return atts;
5653
},
5754
trueAtts: function trueAtts() {
58-
var atts = _.omit(this.atts, 'trueLabel', 'falseLabel');
55+
var atts = _.omit(this.atts, 'trueLabel', 'falseLabel', 'data-schema-key');
5956
if (this.value === true) {
6057
atts.checked = "";
6158
}
6259
return atts;
60+
},
61+
dsk: function () {
62+
return {'data-schema-key': this.atts['data-schema-key']};
6363
}
6464
});
65-

templates/bootstrap3/bootstrap3.html

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -138,11 +138,13 @@ <h3 class="panel-title">{{this}}</h3>
138138
</template>
139139

140140
<template name="afBooleanRadioGroup_bootstrap3">
141-
<div class="radio">
142-
<label><input type="radio" value="false" name="{{this.name}}" {{falseAtts}} /> {{#with this.atts.falseLabel}}{{this}}{{else}}False{{/with}}</label>
143-
</div>
144-
<div class="radio">
145-
<label><input type="radio" value="true" name="{{this.name}}" {{trueAtts}} /> {{#with this.atts.trueLabel}}{{this}}{{else}}True{{/with}}</label>
141+
<div {{dsk}}>
142+
<div class="radio">
143+
<label><input type="radio" value="false" name="{{this.name}}" {{falseAtts}} /> {{#with this.atts.falseLabel}}{{this}}{{else}}False{{/with}}</label>
144+
</div>
145+
<div class="radio">
146+
<label><input type="radio" value="true" name="{{this.name}}" {{trueAtts}} /> {{#with this.atts.trueLabel}}{{this}}{{else}}True{{/with}}</label>
147+
</div>
146148
</div>
147149
</template>
148150

templates/bootstrap3/bootstrap3.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,17 +128,20 @@ Template["afBooleanSelect_bootstrap3"].helpers(selectHelpers);
128128

129129
Template["afBooleanRadioGroup_bootstrap3"].helpers({
130130
falseAtts: function falseAtts() {
131-
var atts = _.omit(this.atts, 'trueLabel', 'falseLabel');
131+
var atts = _.omit(this.atts, 'trueLabel', 'falseLabel', 'data-schema-key');
132132
if (this.value === false) {
133133
atts.checked = "";
134134
}
135135
return atts;
136136
},
137137
trueAtts: function trueAtts() {
138-
var atts = _.omit(this.atts, 'trueLabel', 'falseLabel');
138+
var atts = _.omit(this.atts, 'trueLabel', 'falseLabel', 'data-schema-key');
139139
if (this.value === true) {
140140
atts.checked = "";
141141
}
142142
return atts;
143+
},
144+
dsk: function () {
145+
return {'data-schema-key': this.atts['data-schema-key']};
143146
}
144147
});

0 commit comments

Comments
 (0)