Module: Hyrax::BasedNearFieldBehavior

Included in:
Forms::ResourceForm
Defined in:
app/forms/concerns/hyrax/based_near_field_behavior.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(descendant) ⇒ Object

Provides compatibility with the behavior of the based_near (location) controlled vocabulary form field. The form expects a ControlledVocabularies::Location object as input and produces a hash like those used with accepts_nested_attributes_for.



7
8
9
# File 'app/forms/concerns/hyrax/based_near_field_behavior.rb', line 7

def self.included(descendant)
  descendant.property :based_near_attributes, virtual: true, populator: :based_near_attributes_populator, prepopulator: :based_near_attributes_prepopulator
end

Instance Method Details

#deserialize(params) ⇒ Object

there is a race condition during validation that leaves the based_near field in an inconsistent state. we skip the unedited based_near for validation and only handle it during attribute population



13
14
15
16
# File 'app/forms/concerns/hyrax/based_near_field_behavior.rb', line 13

def deserialize(params)
  params = deserialize!(params)
  deserializer.new(self).from_hash(params.except('based_near'))
end