Method: Alchemy::Forms::Builder#input

Defined in:
lib/alchemy/forms/builder.rb

#input(attribute_name, options = {}, &block) ⇒ Object

Renders a simple_form input, but uses input alchemy_wrapper



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/alchemy/forms/builder.rb', line 8

def input(attribute_name, options = {}, &block)
  options[:wrapper] = :alchemy

  if object.respond_to?(:attribute_fixed?) && object.attribute_fixed?(attribute_name)
    tooltip_options = {
      content: Alchemy.t(:attribute_fixed, attribute: attribute_name),
      class: "like-hint-tooltip",
      placement: "bottom-start"
    }
    template.(:div, class: "input") do
      label(attribute_name) +
        template.("sl-tooltip", tooltip_options) do
          input_field(attribute_name, disabled: true)
        end
    end
  else
    super
  end
end