Class: Backend::KujakuHelper::Kujaku::MultiChoiceFeather

Inherits:
Feather
  • Object
show all
Defined in:
app/helpers/backend/kujaku_helper.rb

Overview

Multi choice feather permits to select multiple choice in a list

Instance Attribute Summary

Attributes inherited from Feather

#uid

Instance Method Summary collapse

Methods inherited from Feather

#feather_name, feather_name, inherited, #initialize, #inspect

Constructor Details

This class inherits a constructor from Backend::KujakuHelper::Kujaku::Feather

Instance Method Details

#configure(*args) ⇒ Object


133
134
135
136
# File 'app/helpers/backend/kujaku_helper.rb', line 133

def configure(*args)
  @choices = args.last.is_a?(Array) ? args.delete_at(-1) : []
  @name = args.shift || @options.delete(:name) || :c
end

#to_htmlObject


138
139
140
141
142
143
144
145
146
147
148
149
150
# File 'app/helpers/backend/kujaku_helper.rb', line 138

def to_html
  @template.params[@name] ||= []
  html = @template.(:label, @options[:label] || :state.tl)
  for human_name, choice in @choices
    html << @template.(:span, class: 'radio') do
      @template.(:label, for: "#{@name}_#{choice}") do
        @template.check_box_tag("#{@name}[]", choice, @template.params[@name].include?(choice.to_s), id: "#{@name}_#{choice}") <<
          ' '.html_safe << human_name
      end
    end
  end
  html
end