Module: Para::FormBuilder::Settings

Defined in:
lib/para/form_builder/settings.rb

Instance Method Summary collapse

Instance Method Details

#settings_input(name, options = {}, &block) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/para/form_builder/settings.rb', line 4

def settings_input(name, options = {}, &block)
  options.reverse_merge!(as: :setting)

  setting = ::Settings.get(name, options[:type])

  input(name, options) do
    fields_for(:settings, setting) do |fields|
      fields.hidden_field(:key) +
      fields.hidden_field(:_type) +

      if block
        block.call(fields)
      else
        fields.text_field(:value, class: 'form-control')
      end
    end
  end
end