Class: Locomotive::API::Forms::ContentTypeFieldForm
- Defined in:
- app/api/locomotive/api/forms/content_type_field_form.rb
Instance Attribute Summary collapse
-
#content_type_service ⇒ Object
Returns the value of attribute content_type_service.
-
#existing_field ⇒ Object
Returns the value of attribute existing_field.
Attributes inherited from BaseForm
Instance Method Summary collapse
-
#initialize(content_type_service, existing_field, attributes) ⇒ ContentTypeFieldForm
constructor
A new instance of ContentTypeFieldForm.
- #select_options=(options) ⇒ Object
- #target=(slug) ⇒ Object
Methods inherited from BaseForm
attributes, attrs, define_attribute, #persisted?, #serializable_hash, #set_attribute
Constructor Details
#initialize(content_type_service, existing_field, attributes) ⇒ ContentTypeFieldForm
Returns a new instance of ContentTypeFieldForm.
15 16 17 18 19 |
# File 'app/api/locomotive/api/forms/content_type_field_form.rb', line 15 def initialize(content_type_service, existing_field, attributes) self.content_type_service = content_type_service self.existing_field = existing_field super(attributes) end |
Instance Attribute Details
#content_type_service ⇒ Object
Returns the value of attribute content_type_service.
7 8 9 |
# File 'app/api/locomotive/api/forms/content_type_field_form.rb', line 7 def content_type_service @content_type_service end |
#existing_field ⇒ Object
Returns the value of attribute existing_field.
7 8 9 |
# File 'app/api/locomotive/api/forms/content_type_field_form.rb', line 7 def existing_field @existing_field end |
Instance Method Details
#select_options=(options) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'app/api/locomotive/api/forms/content_type_field_form.rb', line 27 def () self. = .map do |attributes| if (name = attributes['name']).is_a?(Hash) # deal with translations translations = attributes['name_translations'] = attributes.delete('name') name = translations[content_type_service.site.default_locale] end attach_id_to_option(name, attributes) attributes end end |
#target=(slug) ⇒ Object
21 22 23 24 25 |
# File 'app/api/locomotive/api/forms/content_type_field_form.rb', line 21 def target=(slug) if content_type = self.content_type_service.find_by_slug(slug).first self.class_name = content_type.entries_class_name end end |