Module: Trestle::FormHelper
- Defined in:
- app/helpers/trestle/form_helper.rb
Constant Summary collapse
- IDENTITY_FIELD_ERROR_PROC =
Proc.new { |html_tag, instance| html_tag }
Instance Method Summary collapse
- #form ⇒ Object
- #render_sidebar_as_tab? ⇒ Boolean
- #sidebar(&block) ⇒ Object
- #trestle_form_for(instance, options = {}, &block) ⇒ Object
- #with_form(form) ⇒ Object
- #with_identity_field_error_proc ⇒ Object
Instance Method Details
#form ⇒ Object
35 36 37 |
# File 'app/helpers/trestle/form_helper.rb', line 35 def form @_trestle_form end |
#render_sidebar_as_tab? ⇒ Boolean
43 44 45 |
# File 'app/helpers/trestle/form_helper.rb', line 43 def dialog_request? && content_for?(:sidebar) end |
#sidebar(&block) ⇒ Object
39 40 41 |
# File 'app/helpers/trestle/form_helper.rb', line 39 def (&block) content_for(:sidebar, &block) end |
#trestle_form_for(instance, options = {}, &block) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'app/helpers/trestle/form_helper.rb', line 5 def trestle_form_for(instance, ={}, &block) [:builder] ||= Form::Builder [:as] ||= admin.parameter_name [:data] ||= {} [:data].reverse_merge!(remote: true, type: :html, behavior: "trestle-form", turbolinks: false) form_for(instance, ) do |f| with_identity_field_error_proc do with_form(f) { yield f } end end end |
#with_form(form) ⇒ Object
19 20 21 22 23 24 |
# File 'app/helpers/trestle/form_helper.rb', line 19 def with_form(form) @_trestle_form = form yield form if block_given? ensure @_trestle_form = nil end |
#with_identity_field_error_proc ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'app/helpers/trestle/form_helper.rb', line 26 def with_identity_field_error_proc original_field_error_proc = ::ActionView::Base.field_error_proc ::ActionView::Base.field_error_proc = IDENTITY_FIELD_ERROR_PROC yield if block_given? ensure ::ActionView::Base.field_error_proc = original_field_error_proc end |