Module: Flexite::EntriesHelper

Defined in:
app/helpers/flexite/entries_helper.rb

Constant Summary collapse

ENTRY_TYPE_OPTIONS =
[
  ['String', 'Flexite::StrEntry'],
  ['Symbol', 'Flexite::SymEntry'],
  ['Boolean', 'Flexite::BoolEntry'],
  ['Array', 'Flexite::ArrEntry'],
  ['Integer', 'Flexite::IntEntry']
].freeze

Instance Method Summary collapse

Instance Method Details

#entry_type_select(f = nil) ⇒ Object



19
20
21
22
23
24
25
# File 'app/helpers/flexite/entries_helper.rb', line 19

def entry_type_select(f = nil)
  if f.present?
    f.select :type, options_for_select(ENTRY_TYPE_OPTIONS), {}, class: 'form-control'
  else
    select_tag :new_entry_type, options_for_select(ENTRY_TYPE_OPTIONS), class: 'form-control'
  end
end

#render_entries(entries, form) ⇒ Object



11
12
13
14
15
16
17
# File 'app/helpers/flexite/entries_helper.rb', line 11

def render_entries(entries, form)
   :div, id: "#{form.object_name}-array-entries-#{form.options[:index]}" do
    entries.each_with_index do |entry, index|
      concat render_entry(entry, form, index)
    end
  end
end