Module: DefaultForm::ViewHelper
- Defined in:
- lib/default_form/view_helper.rb
Instance Method Summary collapse
- #form_object(record = nil, builder: DefaultForm::FormBuilder, **options) ⇒ Object
-
#form_with(**options, &block) ⇒ Object
theme: :default.
-
#xx_form_with(**options, &block) ⇒ Object
todo support dynamic keys.
Instance Method Details
#form_object(record = nil, builder: DefaultForm::FormBuilder, **options) ⇒ Object
6 7 8 9 10 11 12 13 14 |
# File 'lib/default_form/view_helper.rb', line 6 def form_object(record = nil, builder: DefaultForm::FormBuilder, **) object_name = [:scope].to_s if object_name.blank? && record.is_a?(ActiveRecord::Base) object_name = record.class.base_class.model_name.param_key end builder.new(object_name, record, self, ) end |
#form_with(**options, &block) ⇒ Object
theme: :default
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/default_form/view_helper.rb', line 17 def form_with(**, &block) if [:theme].present? && [:theme].end_with?('search') [:url] = url_for unless .key?(:url) [:scope] = '' unless .key?(:scope) [:data] ||= {} [:data][:action] = 'default_valid#filter' end super end |
#xx_form_with(**options, &block) ⇒ Object
todo support dynamic keys
29 30 31 32 33 |
# File 'lib/default_form/view_helper.rb', line 29 def xx_form_with(**, &block) [:model] = ActiveSupport::InheritableOptions.new(_values.symbolize_keys) unless .key?(:model) form_with(**, &block) end |