Class: ActionAdmin::Form::Builder
- Inherits:
-
SimpleForm::FormBuilder
- Object
- SimpleForm::FormBuilder
- ActionAdmin::Form::Builder
- Defined in:
- lib/action_admin/form/builder.rb
Direct Known Subclasses
Instance Method Summary collapse
-
#attempt_mapping_with_custom_namespace(input_name) ⇒ Object
Find namespaced input.
-
#button(type, *args, &block) ⇒ Object
Create form button.
-
#error_notification(options = {}) ⇒ Object
Create error notification.
-
#find_wrapper_mapping(input_type) ⇒ Object
Find field wrapper.
-
#initialize ⇒ Builder
constructor
Initialize form builder.
Constructor Details
#initialize ⇒ Builder
Initialize form builder
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/action_admin/form/builder.rb', line 5 def initialize(*) super @admin = { button_class: 'button', error_notification_class: 'callout alert', default_wrapper: :admin_vertical_form, wrapper_mappings: { check_boxes: :admin_horizontal_radio_and_checkboxes, radio_buttons: :admin_horizontal_radio_and_checkboxes, # boolean: :admin_horizontal_radio_and_checkboxes, datetime: :admin_horizontal_multi_select, date: :admin_horizontal_multi_select, time: :admin_horizontal_multi_select, # file: :admin_horizontal_file_input } } @wrapper = ::SimpleForm.wrapper([:wrapper] || @admin[:default_wrapper]) end |
Instance Method Details
#attempt_mapping_with_custom_namespace(input_name) ⇒ Object
Find namespaced input
53 54 55 56 57 58 59 60 61 |
# File 'lib/action_admin/form/builder.rb', line 53 def attempt_mapping_with_custom_namespace(input_name) ['ActionAdmin', 'Admin'].each do |namespace| if (mapping = attempt_mapping(input_name, namespace.constantize)) return mapping end end nil end |
#button(type, *args, &block) ⇒ Object
Create form button
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/action_admin/form/builder.rb', line 27 def (type, *args, &block) = args..dup [:class] = [@admin[:button_class], [:class]].compact args << if respond_to?(:"#{type}_button") send(:"#{type}_button", *args, &block) else send(type, *args, &block) end end |
#error_notification(options = {}) ⇒ Object
Create error notification
39 40 41 |
# File 'lib/action_admin/form/builder.rb', line 39 def error_notification(={}) Form::ErrorNotification.new(self, ).render end |
#find_wrapper_mapping(input_type) ⇒ Object
Find field wrapper
44 45 46 47 48 49 50 |
# File 'lib/action_admin/form/builder.rb', line 44 def find_wrapper_mapping(input_type) if [:wrapper_mappings] && [:wrapper_mappings][input_type] [:wrapper_mappings][input_type] else @admin[:wrapper_mappings] && @admin[:wrapper_mappings][input_type] end end |