Module: Wallaby::FormHelper
- Included in:
- ResourcesHelper
- Defined in:
- lib/helpers/wallaby/form_helper.rb
Instance Method Summary collapse
- #form_type_partial_render(options = {}, locals = {}, &block) ⇒ Object
- #model_choices(model_decorator) ⇒ Object
Instance Method Details
#form_type_partial_render(options = {}, locals = {}, &block) ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 13 |
# File 'lib/helpers/wallaby/form_helper.rb', line 2 def form_type_partial_render( = {}, locals = {}, &block) form = locals[:form] field_name = locals[:field_name].to_s fail ArgumentError unless form.present? && field_name.present? && form.object.is_a?(Wallaby::ResourceDecorator) locals[:object] = object = form.object locals[:metadata] = object. locals[:field_name] locals[:value] = object.public_send locals[:field_name] render(, locals, &block) or render('string', locals, &block) end |
#model_choices(model_decorator) ⇒ Object
15 16 17 18 19 20 |
# File 'lib/helpers/wallaby/form_helper.rb', line 15 def model_choices(model_decorator) collection = model_servicer(model_decorator).collection Hash.new, current_ability decorate(collection).map do |decorated| [ decorated.to_label, decorated.primary_key_value ] end end |