Module: Formular::Element::Modules::Checkable::InstanceMethods
- Defined in:
- lib/formular/element/modules/checkable.rb
Instance Method Summary collapse
Instance Method Details
#collection ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/formular/element/modules/checkable.rb', line 49 def collection unless collection? [:label_options] = [:control_label_options] return [self] end = @collection ||= [:collection].map do |item| opts = .dup opts[:value] = item.send([:value_method]) opts[:label] = item.send([:label_method]) opts[:id] = if [:id] "#{[:id]}_#{opts[:value]}" else "#{attribute_name || [:name].gsub('[]', '')}_#{opts[:value]}" end self.class.(opts) end end |
#collection? ⇒ Boolean
72 73 74 |
# File 'lib/formular/element/modules/checkable.rb', line 72 def collection? [:collection] end |
#group_label ⇒ Object
38 39 40 41 42 43 |
# File 'lib/formular/element/modules/checkable.rb', line 38 def group_label return '' unless has_group_label? label_opts = .dup label_opts[:content] = label_text builder.checkable_group_label(label_opts).to_s end |
#has_group_label? ⇒ Boolean
45 46 47 |
# File 'lib/formular/element/modules/checkable.rb', line 45 def has_group_label? collection.size > 1 && has_label? end |