Class: Alchemy::Ingredients::SelectEditor

Inherits:
BaseEditor
  • Object
show all
Defined in:
app/components/alchemy/ingredients/select_editor.rb

Instance Attribute Summary

Attributes inherited from BaseEditor

#html_options, #ingredient

Instance Method Summary collapse

Methods inherited from BaseEditor

#call, #form_field_id, #form_field_name, #initialize

Constructor Details

This class inherits a constructor from Alchemy::Ingredients::BaseEditor

Instance Method Details

#input_fieldObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'app/components/alchemy/ingredients/select_editor.rb', line 6

def input_field
  if select_values.nil?
    warning(":select_values is nil",
      <<-MSG.strip_heredoc
        <strong>No select values given.</strong>
        <br>Please provide <code>select_values</code> on the
        ingredient definition <code>settings</code> in
        <code>elements.yml</code>.
      MSG
    )
  else
    options_tags = if select_values.is_a?(Hash)
      grouped_options_for_select(select_values, value)
    else
      options_for_select(select_values, value)
    end
    select_tag form_field_name, options_tags, {
      id: form_field_id,
      class: ["ingredient-editor-select"],
      is: "alchemy-select",
      multiple: settings[:multiple],
      disabled: !editable?
    }
  end
end