|
26 | 26 | %div{id: component_id, ref: "select.multiple.#{attr_key}", "init-value": init_value} |
27 | 27 | - if options[:options].is_a?(Hash) |
28 | 28 | - options[:options].each do |key, value| |
29 | | - %input{@tag_attributes, |
| 29 | + %input{@tag_attributes.except(:id), |
| 30 | + id: id_for_option(value), |
30 | 31 | type: :checkbox, |
31 | 32 | "#{model_binding}": input_key, |
32 | 33 | "@change": "inputChanged(\"#{attr_key}\")", |
33 | 34 | "value-type": options_type, |
34 | 35 | name: value, |
35 | 36 | value: key}/ |
36 | | - %label=value |
| 37 | + %label{for: id_for_option(value)}=value |
37 | 38 | - if options[:options].is_a?(Array) |
38 | 39 | - options[:options].each do |value| |
39 | | - %input{@tag_attributes, |
| 40 | + %input{@tag_attributes.except(:id), |
| 41 | + id: id_for_option(value), |
40 | 42 | type: :checkbox, |
41 | 43 | "#{model_binding}": input_key, |
42 | 44 | "@change": "inputChanged(\"#{attr_key}\")", |
43 | 45 | "value-type": options_type, |
44 | 46 | name: value, |
45 | 47 | value: value}/ |
46 | | - %label=value |
| 48 | + %label{for: id_for_option(value)}=value |
47 | 49 | %span{class: "errors", "v-if": error_key } |
48 | 50 | %span{class: "error", "v-for": "error in #{error_key}"} |
49 | 51 | {{ error }} |
|
53 | 55 | %div{id: component_id, ref: "select.#{attr_key}", "init-value": init_value} |
54 | 56 | - if options[:options].is_a?(Hash) |
55 | 57 | - options[:options].each do |key, value| |
56 | | - %input{@tag_attributes, |
| 58 | + %input{@tag_attributes.except(:id), |
57 | 59 | type: :radio, |
| 60 | + id: id_for_option(value), |
58 | 61 | "#{model_binding}": input_key, |
59 | 62 | "@change": "inputChanged(\"#{attr_key}\")", |
60 | 63 | "value-type": options_type, |
61 | 64 | name: "#{attr_key}_#{key}", |
62 | 65 | value: key}/ |
63 | | - %label=value |
| 66 | + %label{for: id_for_option(value)}=value |
64 | 67 | - if options[:options].is_a?(Array) |
65 | 68 | - options[:options].each do |value| |
66 | | - %input{@tag_attributes, |
| 69 | + %input{@tag_attributes.except(:id), |
67 | 70 | type: :radio, |
| 71 | + id: id_for_option(value), |
68 | 72 | "#{model_binding}": input_key, |
69 | 73 | "@change": "inputChanged(\"#{attr_key}\")", |
70 | 74 | "value-type": options_type, |
71 | 75 | name: "#{attr_key}_#{value}", |
72 | 76 | value: value}/ |
73 | | - %label=value |
| 77 | + %label{for: id_for_option(value)}=value |
74 | 78 | %span{class: "errors", "v-if": error_key } |
75 | 79 | %span{class: "error", "v-for": "error in #{error_key}"} |
76 | 80 | {{ error }} |
0 commit comments