Sha256: 662a001a71b35b599b9798f3c269463d4dd6625bc04f06bb14bcffdb53cc62fa
Contents?: true
Size: 1.48 KB
Versions: 58
Compression:
Stored size: 1.48 KB
Contents
module Effective module FormInputs class CheckBox < Effective::FormInput def to_html(&block) case layout when :horizontal build_wrapper do content_tag(:div, '', class: 'col-sm-2') + content_tag(:div, build_content(&block), class: 'col-sm-10') end else build_content(&block) end end def build_content(&block) build_check_box_wrap { build_input(&block) + build_label + build_feedback + build_hint } end def build_check_box_wrap(&block) if custom? content_tag(:div, yield, class: 'form-group custom-control custom-checkbox' + (inline? ? ' custom-control-inline' : '')) else content_tag(:div, yield, class: 'form-check' + (inline? ? ' form-check-inline' : '')) end end def label_options if custom? { class: 'custom-control-label' } else { class: 'form-check-label' } end end def input_html_options if custom? { class: 'custom-control-input', id: unique_id } else { class: 'form-check-input', id: unique_id } end end private def inline? # default false return @inline unless @inline.nil? @inline = (options[:input].delete(:inline) == true) end def custom? # default true return @custom unless @custom.nil? @custom = (options.delete(:custom) != false) end end end end
Version data entries
58 entries across 58 versions & 1 rubygems