Sha256: 5f26e065638df452b7faa7aee22685d15490501921b476bc547663c229dc09ac
Contents?: true
Size: 1.45 KB
Versions: 2
Compression:
Stored size: 1.45 KB
Contents
class RadioWithClearInput < SimpleForm::Inputs::CollectionInput def label "" end def input_type "radio" end def input input_options[:collection_wrapper_tag] ||= options.fetch(:collection_wrapper_tag, SimpleForm.collection_wrapper_tag) input_options[:item_wrapper_class] ||= 'uc-form-collection-item' # Create a duplicate hidden field with a value of nil on top of existing # radio buttons so a user can clear their selection. # Selected radio buttons override this value. hidden_field = @builder.hidden_field( attribute_name, input_html_options.merge(:value => nil).merge( class: input_html_classes.join(' ') ) ) label_method, value_method = detect_collection_methods input_dom = @builder.send(:"collection_#{input_type}_buttons", attribute_name, collection, value_method, label_method, input_options, input_html_options) dom = <<-STRING <fieldset class='radio_buttons normal row uc-form-fieldset-radio-with-clear'> <div class="three fifths small-tablet pad-right"> <legend class="uc-form-legend">#{input_options[:label]}</legend> </div> <div class='options two fifths small-tablet align-right' data-presents='radio_with_clear'> #{hidden_field} #{input_dom} <a href='#'>clear</a> </div> </fieldset> STRING dom.html_safe end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
undercase-0.2.57 | app/inputs/radio_with_clear_input.rb |
undercase-0.2.29 | app/inputs/radio_with_clear_input.rb |