Module: Amrita2View::FormHelper
- Included in:
- ActionView::Base
- Defined in:
- lib/amrita2/rails_bridge.rb
Defined Under Namespace
Classes: FormFieldHelper
Instance Method Summary collapse
Instance Method Details
#amrita_define_form(*args, &block) ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/amrita2/rails_bridge.rb', line 61 def amrita_define_form(*args, &block) record = args.first method = :form_for format = :as_hash case h = args.last when Hash method = h.delete(:form_method) || method format = h.delete(:amrita_format) || format end amrita_form_hook(method, *args) do |f| FormFieldHelper.new(record, f) do |ff| block.call(ff) end.send(format) end end |
#amrita_form_hook(meth, *args, &block) ⇒ Object
78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/amrita2/rails_bridge.rb', line 78 def amrita_form_hook(meth, *args, &block) view = self hook = Amrita2::Core::Hook.new do _erbout = stream view.instance_eval do self.send(meth, *args) do |f| data = block.call(f) hook.render_me_with(data) end end end end |