Module: PagesCore::Admin::PageBlocksHelper
- Included in:
- Admin::PagesHelper
- Defined in:
- app/helpers/pages_core/admin/page_blocks_helper.rb
Instance Method Summary collapse
- #page_block_field(form, block_name, block_options) ⇒ Object
- #page_block_select(form, block_name, block_options) ⇒ Object
- #page_block_text_field(form, block_name, block_options) ⇒ Object
Instance Method Details
#page_block_field(form, block_name, block_options) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'app/helpers/pages_core/admin/page_blocks_helper.rb', line 6 def page_block_field(form, block_name, ) labelled_field( if [:type] == :select page_block_select(form, block_name, ) else page_block_text_field(form, block_name, ) end, [:title], errors: form.object.errors[block_name], description: [:description] ) end |
#page_block_select(form, block_name, block_options) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/helpers/pages_core/admin/page_blocks_helper.rb', line 19 def page_block_select(form, block_name, ) opts = (form, ) opts = opts.call if opts.is_a?(Proc) opts = opts.map { |v| [v, v] } unless nested_array?(opts) opts = ([["", nil]] + opts).uniq value = form.object.send(block_name) opts << [value, value] unless opts.map(&:last).include?(value) form.send(:select, block_name, opts) end |
#page_block_text_field(form, block_name, block_options) ⇒ Object
31 32 33 34 35 36 37 |
# File 'app/helpers/pages_core/admin/page_blocks_helper.rb', line 31 def page_block_text_field(form, block_name, ) form.send( [:size] == :field ? :text_field : :rich_text_area, block_name, () ) end |