Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed custom field defaults being prematurely updated #15377

Merged

Conversation

marcusmoore
Copy link
Collaborator

Description

This PR fixes an issue where attempting to update an asset model but getting a validation error still updated custom field default values even though the user is redirected back to the form:

custom.field.validation.issue.mp4

I manually disabled required for the name input to demonstrate the issue above.

The issue was we were updating the custom field value defaults before calling $model->save() and a failure at model level validation means the user would be redirected back but the defaults had already been updated.

We could probably update and utilize the StoreAssetModelRequest here but I found this as part of other work I'm doing and didn't want to get too distracted.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Copy link

what-the-diff bot commented Aug 22, 2024

PR Summary

  • Optimized Asset Model Updation
    The asset model saving process has been enhanced. We no longer remove custom fields before saving. Now, conditional code will decide whether to assign default field values based on the input received. This leads to more efficient and intelligent saving processes. Additionally, we are only moving to the next step if the model's 'End of life' attribute has been altered.

  • Refined Testing Methods
    Improvements made to our testing methods using the 'CustomField' and 'CustomFieldset' models. The 'asset model storage' test now incorporates an updated 'PUT' method test. Also, new tests have been added to check for validation errors and updating of default field values. Special attention has been given to affirm that default field values remain constant even when a validation error occurs. They can also be updated if required. This refined testing process assures the stability and integrity of our application.

@snipe snipe merged commit 78d355f into snipe:develop Aug 23, 2024
9 checks passed
@marcusmoore marcusmoore deleted the fixes/custom-field-values-on-validation-error branch August 23, 2024 20:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants