@@ -15,7 +15,7 @@ public class FormCheckboxGroup: BasicTag {
15
15
public func run( arguments: [ Argument ] ) throws -> Node ? {
16
16
17
17
/*
18
- #form:checkboxgroup(key, value, fieldset)
18
+ #form:checkboxgroup(key, value, fieldset, attr1, attr2 etc )
19
19
20
20
Arguments:
21
21
[0] = The name of the input (the key that gets posted) *
@@ -37,8 +37,6 @@ public class FormCheckboxGroup: BasicTag {
37
37
)
38
38
], requiring: ["send_mail"])
39
39
40
- #form:checkboxgroup("send_mail", send_mail, fieldset)
41
-
42
40
expected output if fieldset is valid and value resolves to true:
43
41
<div class="form-group">
44
42
<div class="checkbox">
@@ -70,7 +68,7 @@ public class FormCheckboxGroup: BasicTag {
70
68
</div>
71
69
*/
72
70
73
- guard arguments. count = = 3 ,
71
+ guard arguments. count > = 3 ,
74
72
let inputName: String = arguments [ 0 ] . value? . string,
75
73
let fieldsetNode = arguments [ 2 ] . value? . nodeObject
76
74
else {
@@ -103,11 +101,23 @@ public class FormCheckboxGroup: BasicTag {
103
101
template. append ( " <label> " )
104
102
105
103
if ( inputValue == true ) {
106
- template. append ( " <input type='checkbox' id=' \( inputName) ' name=' \( inputName) ' value=' \( inputName) ' checked/> " )
104
+ template. append ( " <input type='checkbox' id=' \( inputName) ' name=' \( inputName) ' value=' \( inputName) ' checked " )
107
105
} else {
108
- template. append ( " <input type='checkbox' id=' \( inputName) ' name=' \( inputName) ' value=' \( inputName) '/> " )
106
+ template. append ( " <input type='checkbox' id=' \( inputName) ' name=' \( inputName) ' value=' \( inputName) ' " )
107
+ }
108
+
109
+ // Add custom attributes
110
+ if arguments. count > 3 {
111
+ let max = arguments. count - 1
112
+ for index in 3 ... max {
113
+ if let argument = arguments [ index] . value? . string {
114
+ template. append ( " " + argument)
115
+ }
116
+ }
109
117
}
110
118
119
+ template. append ( " /> " )
120
+
111
121
template. append ( " \( label) " )
112
122
113
123
template. append ( " </label> " )
0 commit comments