Module: RulesEngineView::FormStyles
- Included in:
- FormBuilder
- Defined in:
- lib/rules_engine_view/form_styles.rb
Instance Method Summary collapse
- #re_build_form_data(value, options = {}) ⇒ Object
- #re_build_form_field(value, options = {}) ⇒ Object
- #re_build_form_label(value, options = {}) ⇒ Object
- #re_data_span(options) ⇒ Object
- #re_error_on_tag(message) ⇒ Object
- #re_field_span(options) ⇒ Object
- #re_label_span(options) ⇒ Object
- #re_options_exclude(options) ⇒ Object
Instance Method Details
#re_build_form_data(value, options = {}) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/rules_engine_view/form_styles.rb', line 37 def re_build_form_data value, = {} result = "<div class='re-form-data".html_safe result << "-error" if .include?(:error) && ![:error].blank? result << " re-form-disabled" if .include?(:disabled) && [:disabled] result << " #{[:class]}" if .include?(:class) result << " span-#{[:span] || '8'}" result << " last" result << "'" result << " id='form_data_#{[:id]}'" if .include?(:id) result << ">".html_safe result << value if .include?(:text) && ![:text].blank? result << "<span class='form-text'>".html_safe result << [:text] result << "</span>".html_safe end if .include?(:hint) && ![:hint].blank? && (!.include?(:error) || [:error].blank?) result << "<span class='form-hint'>".html_safe result << [:hint] result << "</span>".html_safe end if .include?(:error) && ![:error].blank? result << "<span class='form-error-message'>".html_safe result << [:error] result << "</span>".html_safe end result << "</div>".html_safe result end |
#re_build_form_field(value, options = {}) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/rules_engine_view/form_styles.rb', line 4 def re_build_form_field(value, = {}) result = ''.html_safe result << "<div class='re-form-field".html_safe result << " re-form-disabled" if .include?(:disabled) && [:disabled] result << " #{[:class]}" if .include?(:class) result << " span-#{[:span] || '12'}" result << " clear'" result << " id='form_field_#{[:id]}'" unless [:id].blank? result << ">".html_safe result << value result << "</div>".html_safe result end |
#re_build_form_label(value, options = {}) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/rules_engine_view/form_styles.rb', line 18 def re_build_form_label value, = {} result = "<div class='re-form-label".html_safe result << "-error" if .include?(:error) && ![:error].blank? result << " re-form-disabled" if .include?(:disabled) && [:disabled] result << " #{[:class]}" if .include?(:class) result << " span-#{[:span] || '4'}" result << "'" result << " id='re_form_label_#{[:id]}'" unless [:id].blank? result << ">".html_safe result << value if .include?(:required) && [:required] result << "<span class='re-form-required".html_safe result << " re-form-disabled" if .include?(:disabled) && [:disabled] result << "'>*</span>".html_safe end result << "</div>".html_safe result end |
#re_data_span(options) ⇒ Object
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/rules_engine_view/form_styles.rb', line 82 def re_data_span() span = [: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 |
#re_error_on_tag(message) ⇒ Object
103 104 105 106 107 108 109 |
# File 'lib/rules_engine_view/form_styles.rb', line 103 def re_error_on_tag() result = ''.html_safe result << '<div class="re-error"><p>'.html_safe result << result << '</p></div>'.html_safe result end |
#re_field_span(options) ⇒ Object
99 100 101 |
# File 'lib/rules_engine_view/form_styles.rb', line 99 def re_field_span() re_label_span() + re_data_span() end |
#re_label_span(options) ⇒ Object
71 72 73 74 75 76 77 78 79 80 |
# File 'lib/rules_engine_view/form_styles.rb', line 71 def re_label_span() span = [: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 |
#re_options_exclude(options) ⇒ Object
67 68 69 |
# File 'lib/rules_engine_view/form_styles.rb', line 67 def () .except(:error, :hint, :label, :text, :required, :span) end |