module RulesView module FormStyles def re_build_form_field(value, options = {}) result = ''.html_safe result << "
".html_safe result << value result << "
".html_safe result end def re_build_form_label value, options = {} result = "
".html_safe result << value if options.include?(:required) && options[:required] result << "*".html_safe end result << "
".html_safe result end def re_build_form_data value, options = {} result = "
".html_safe result << value if options.include?(:text) && !options[:text].blank? result << "".html_safe result << options[:text] result << "".html_safe end if options.include?(:hint) && !options[:hint].blank? && (!options.include?(:error) || options[:error].blank?) result << "".html_safe result << options[:hint] result << "".html_safe end if options.include?(:error) && !options[:error].blank? result << "".html_safe result << options[:error] result << "".html_safe end result << "
".html_safe result end def re_options_exclude(options) options.except(:error, :hint, :label, :text, :required, :span) end def re_label_span(options) span = options[:span] if span =~ %r{^\d+x\d+$} return span.split("x")[0].to_i elsif span =~ %r{^\d+$} return span.to_i end return 4 end def re_data_span(options) span = options[:span] if span =~ %r{^\d+x\d+$} return span.split("x")[1].to_i elsif span =~ %r{^\d+$} if span.to_i < 8 return 8 - span.to_i elsif span.to_i < 16 return 16 - span.to_i else return 24 - span.to_i end end return 8 end def re_field_span(options) re_label_span(options) + re_data_span(options) end def re_error_on_tag(message) result = ''.html_safe result << '

'.html_safe result << message result << '

'.html_safe result end end end