Sha256: eafaacf09ac83da73812310ab46149f224134f7c81f3a64d4905ac1cab4643c3
Contents?: true
Size: 1.03 KB
Versions: 39
Compression:
Stored size: 1.03 KB
Contents
module Formtastic module Inputs class SelectableCheckBoxesInput < CheckBoxesInput def to_html input_wrapping do choices_wrapping do legend_html << hidden_field_for_all << choices_group_wrapping do select_all_html + collection.map { |choice| choice_wrapping(choice_wrapping_html_options(choice)) do choice_html(choice) end }.join("\n").html_safe end end end end def select_all_html choice_wrapping({}) do check_box = template.check_box_tag(nil, nil, false, :onclick => <<-JS selector = $(this); condition = selector.is(':checked'); selector.closest('.choices-group').find('[type=checkbox]').attr('checked', condition); JS ) template.content_tag(:label, check_box << I18n.t('select_all') ) end end end end end
Version data entries
39 entries across 39 versions & 1 rubygems