Class: Backend::KujakuHelper::Kujaku::NeedleChoiceFeather

Inherits:
ChoiceFeather show all
Defined in:
app/helpers/backend/kujaku_helper.rb

Overview

Multi choice feather permits to select one choice in a long list Like a “search a needle in hay”

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


175
176
177
178
# File 'app/helpers/backend/kujaku_helper.rb', line 175

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

#to_htmlObject


180
181
182
183
184
185
186
187
188
# File 'app/helpers/backend/kujaku_helper.rb', line 180

def to_html
  @template.params[@name] ||= @selection.first.second if @selection && @selection.first
  html = @template.(:label, @options[:label] || :options.tl)
  html << ' '.html_safe
  html << @template.(:span, class: :slc) do
    @template.select_tag(@name, @template.options_for_select(@selection, @options[:selected] || @template.params[@name]))
  end
  html
end