Skip to content

Commit

Permalink
Merge pull request #76 from russellthorn/update-radiobutton-helper
Browse files Browse the repository at this point in the history
Update helper to adopt markup for new radio buttons for new styling
  • Loading branch information
rpowis authored Aug 11, 2017
2 parents e83255c + 37a3d48 commit 9dc5212
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,7 @@

@radioOptions.map { case (value, label) =>
@defining(s"${elements.field.name}-${value.toLowerCase.replace(" ","_")}") { inputId =>
<label for="@inputId"
@elements.args.get('_labelClass).map{labelClass => class="@[email protected]( _ == value).map{_ => selected}"}>
@if(!labelAfter) {
@if(elements.args.get('_stackedLabel)) {
@if(label.split(" ").length < 2) {<br>@label
} else {
@for( (l, index) <- label.split(" ").zipWithIndex) {
@if(index != 0) {<br>}@l
}
}
} else { @label }
}
<div class="multiple-choice">
<input
type="radio"
id="@inputId"
Expand All @@ -52,17 +41,32 @@
@elements.args.get('_inputClass).map{inputClass => class="@inputClass"}
@if(elements.args.contains('_dataAttributes) ){ @elements.args.get('_dataAttributes)}
@field.value.filter( _ == value).map{_ => checked="checked"}/>
@if(labelAfter) {
@if(elements.args.get('_stackedLabel)) {
@if(label.split(" ").length < 2) {<br>@label
} else {
@for( (l, index) <- label.split(" ").zipWithIndex) {
@if(index != 0) {<br>}@l

<label for="@inputId"
@elements.args.get('_labelClass).map{labelClass => class="@[email protected]( _ == value).map{_ => selected}"}>
@if(!labelAfter) {
@if(elements.args.get('_stackedLabel)) {
@if(label.split(" ").length < 2) {<br>@label
} else {
@for( (l, index) <- label.split(" ").zipWithIndex) {
@if(index != 0) {<br>}@l
}
}
} else { @label }
}

@if(labelAfter) {
@if(elements.args.get('_stackedLabel)) {
@if(label.split(" ").length < 2) {<br>@label
} else {
@for( (l, index) <- label.split(" ").zipWithIndex) {
@if(index != 0) {<br>}@l
}
}
}
} else { @label }
}
</label>
} else { @label }
}
</label>
</div>
}
}
</fieldset>
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class InputRadioGroupSpec extends WordSpec with Matchers {
val radioGroupField = radioGroupFieldset.getElementsByTag("label").first()
radioGroupField.attr("class") should include("myLabelClass")
radioGroupField.ownText() shouldBe "myLabel"
val radioGroupFieldInput = radioGroupField.getElementsByTag("input")
val radioGroupFieldInput = radioGroupFieldset.getElementsByTag("input")
radioGroupFieldInput.attr("class") shouldBe "inputClass"
}

Expand Down

0 comments on commit 9dc5212

Please sign in to comment.