Class: Alchemy::Ingredients::BaseEditor
- Inherits:
-
ViewComponent::Base
- Object
- ViewComponent::Base
- Alchemy::Ingredients::BaseEditor
- Defined in:
- app/components/alchemy/ingredients/base_editor.rb
Direct Known Subclasses
BooleanEditor, ColorEditor, DatetimeEditor, FileEditor, HeadlineEditor, HtmlEditor, LinkEditor, NodeEditor, NumberEditor, PageEditor, PictureEditor, RichtextEditor, SelectEditor, TextEditor
Instance Attribute Summary collapse
-
#html_options ⇒ Object
readonly
Returns the value of attribute html_options.
-
#ingredient ⇒ Object
readonly
Returns the value of attribute ingredient.
Instance Method Summary collapse
- #call ⇒ Object
-
#form_field_id(column = "value") ⇒ Object
Returns a unique string to be passed to a form field id.
-
#form_field_name(column = "value") ⇒ Object
Returns a string to be passed to Rails form field helpers.
-
#initialize(ingredient, html_options: {}) ⇒ BaseEditor
constructor
A new instance of BaseEditor.
Constructor Details
#initialize(ingredient, html_options: {}) ⇒ BaseEditor
Returns a new instance of BaseEditor.
28 29 30 31 32 33 |
# File 'app/components/alchemy/ingredients/base_editor.rb', line 28 def initialize(ingredient, html_options: {}) raise ArgumentError, "Ingredient missing!" if ingredient.nil? @ingredient = ingredient = end |
Instance Attribute Details
#html_options ⇒ Object (readonly)
Returns the value of attribute html_options.
26 27 28 |
# File 'app/components/alchemy/ingredients/base_editor.rb', line 26 def end |
#ingredient ⇒ Object (readonly)
Returns the value of attribute ingredient.
26 27 28 |
# File 'app/components/alchemy/ingredients/base_editor.rb', line 26 def ingredient @ingredient end |
Instance Method Details
#call ⇒ Object
35 36 37 38 39 40 41 |
# File 'app/components/alchemy/ingredients/base_editor.rb', line 35 def call tag.div(class: css_classes, data: data_attributes, id: dom_id(ingredient)) do concat ingredient_id_field concat ingredient_label concat input_field end end |
#form_field_id(column = "value") ⇒ Object
Returns a unique string to be passed to a form field id.
65 66 67 |
# File 'app/components/alchemy/ingredients/base_editor.rb', line 65 def form_field_id(column = "value") "element_#{element.id}_ingredient_#{ingredient.id}_#{column}" end |
#form_field_name(column = "value") ⇒ Object
Returns a string to be passed to Rails form field helpers.
Example:
<%= text_field_tag text_editor.form_field_name, text_editor.value %>
Options:
You can pass an Ingredient column_name. Default is ‘value’
Example:
<%= text_field_tag text_editor.form_field_name(:link), text_editor.value %>
57 58 59 |
# File 'app/components/alchemy/ingredients/base_editor.rb', line 57 def form_field_name(column = "value") "element[ingredients_attributes][#{form_field_counter}][#{column}]" end |