Closed sjproctor closed 1 month ago
Possibly related: When editing a work, fields that can contain multiple inputs often have a blank second value added.
Issue seems to be happening here.
@sjproctor to attach screenshot of params. Form looks as expected before this point. it issue can be see after evaluating 'action', here. "" values should be nil. [ " " ] values should be [ ]
Sarah has a bandaid in place for now but we still need to figure this out because anyone editing/creating a record from the frontend will introduce bad data in the system.
until we can figure out the WHY, maybe we need to clean the params?
#psuedocode
def clean_params(params)
params.each do |key, value|
if value.is_a?(ActionController::Parameters)
clean_params(value) # Recursively clean nested hashes
elsif value.is_a?(Array)
params[key] = value == [""] ? [] : value # Convert [""] to []
else
params[key] = value.empty? ? nil : value # Convert "" to nil
end
end
end
# Call the method on your params
clean_params(params)
app/samvera/hyrax-webapp/gems/hyrax/app/controllers/concerns/hyrax/works_controller_behavior.rb
In Hyrax the params also get populated with [""]
or ""
, so I'm thinking something is happening in the action
This problem is being addressed in https://github.com/scientist-softserv/adventist_knapsack/issues/771
Summary
Data fields that appear blank are rendering on the works show page. This is because at some point during form submission some attributes get assigned
[""]
if there is no data.The commit
17489e60223a00d62b36525adc66c09ce1fa630a
on Adventist Knapsack provided a temporary solution for the client.The fields are:
Acceptance Criteria
Testing Instructions
app/renderers/hyrax/renderers/attribute_renderer.rb
fromreturn markup if Array.wrap(values).first.blank? && !options[:include_empty]
toreturn markup if values.blank? && !options[:include_empty]
Notes
This appears to happen most often on data values. Ref: https://github.com/scientist-softserv/adventist_knapsack/issues/771