Module: HandyForm::Helpers
- Defined in:
- lib/handy_form/helpers.rb
Instance Method Summary collapse
- #error_tag(options) ⇒ Object
- #handy_field_wrapper(field, field_label, options = {}) ⇒ Object
- #handy_form_for(record_or_name_or_array, *args, &proc) ⇒ Object
- #hint_tag(options) ⇒ Object
- #merge_builder_options!(options) ⇒ Object
Instance Method Details
#error_tag(options) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/handy_form/helpers.rb', line 47 def error_tag() return "" if .nil? case when String text = = {:class => "error-message"} when Hash text = build_error_string(.delete(:text)) merge_option_strings!(, :class, "error-message") end content_tag(:div, text, ) end |
#handy_field_wrapper(field, field_label, options = {}) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/handy_form/helpers.rb', line 16 def handy_field_wrapper(field, field_label, = {}) [:wrapper] ||= {} merge_option_strings!([:wrapper], :class, "row") hint = hint_tag(.delete(:hint)) error = error_tag(.delete(:error)) unless .delete(:input_first) content_tag(:div, ( field_label.html_safe + field.html_safe + hint.html_safe + error.html_safe ), [:wrapper]).html_safe else content_tag(:div, (field.html_safe + field_label.html_safe + hint.html_safe + error.html_safe), [:wrapper]).html_safe end end |
#handy_form_for(record_or_name_or_array, *args, &proc) ⇒ Object
3 4 5 6 7 8 |
# File 'lib/handy_form/helpers.rb', line 3 def handy_form_for(record_or_name_or_array, *args, &proc) raise ArgumentError, "Missing block" unless block_given? = args. form_for(record_or_name_or_array, *(args << ), &proc) end |
#hint_tag(options) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/handy_form/helpers.rb', line 33 def hint_tag() return "" if .nil? case when String text = = {:class => "hint"} when Hash text = .delete(:text) merge_option_strings!(, :class, "error-message") end content_tag(:div, text, ) end |