mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-03 02:21:33 +00:00
Improve admin variants controller create action, it doesn't try to set on_hand and on_demand if there are previous errors in the variant
This commit is contained in:
@@ -6,9 +6,13 @@ Spree::Admin::VariantsController.class_eval do
|
||||
def create
|
||||
on_demand = params[:variant].delete(:on_demand)
|
||||
on_hand = params[:variant].delete(:on_hand)
|
||||
|
||||
super
|
||||
@object.on_demand = on_demand if @object.present?
|
||||
@object.on_hand = on_hand.to_i if @object.present?
|
||||
|
||||
if @object.present? && @object.valid?
|
||||
@object.on_demand = on_demand if on_demand.present?
|
||||
@object.on_hand = on_hand.to_i if on_hand.present?
|
||||
end
|
||||
end
|
||||
|
||||
def search
|
||||
|
||||
Reference in New Issue
Block a user