Sha256: 2a45c0bb1d61d9c3833b55b38453b0c61e20765822447998f87cd57ef0f504d0
Contents?: true
Size: 942 Bytes
Versions: 4
Compression:
Stored size: 942 Bytes
Contents
class DropdownSelectInput < SimpleForm::Inputs::CollectionInput include ActionView::Helpers::TagHelper include ActionView::Context def selected_option collection.find { |x| x[1] == object.send(attribute_name) } end def input content_tag(:span, class: 'dropdown dropdown_select_input') do @builder.hidden_field(attribute_name, input_html_options) + content_tag(:a, class: 'dropdown_toggle_button', 'data-toggle' => 'dropdown') { selected_option[0] } + content_tag(:ul, class: 'dropdown_menu') { collection.map do |x| content_tag(:li, class: selected_option == x ? 'active' : nil) { content_tag(:a, 'data-value' => x[1]) { content_tag(:span, class: 'dropdown_select_input_title') { x[0] } + content_tag(:span, class: 'dropdown_select_input_description') { x[2] } } } end.join('').html_safe } end end end
Version data entries
4 entries across 4 versions & 1 rubygems