Remove required field asterisk from on_hand's field on new products form #6861
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What? Why?
Closes #6159
Even though original issue suggests showing "on hand is a mandatory field" errors using model validations, I believe this would add more complexity, when same trouble can be solved with more simple way.
Default value of
count_on_hand
is defined as0
in database level, thereforeStockItem
with nilcount_on_hand
will be build as0
. In order to detect the violence of presence validation, we would need to add another migration(which removes default value ofcount_on_hand
onStockItem
), and add custom associated validation toProduct
model for checking validity of theStockItem
. And also maybe some changes would be needed regardingconcerns/variant_stock#save_stock
.This PR suggests adding html required attribute to 'on hand' field, and changing it is type from
text_field
tonumber_field
, since it is an integer column.What should we test?
admin/products/new
with deleting 'on hand' field value. HTML required attribute should point that box can not be left blank.Release notes
Change on_hand's field to number_field and add required attribute on new products formRemove required field asterisk from on_hand's field on new products form
User facing changes