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

Remove DBField casting when submitting via forms #11453

Open
1 task
emteknetnz opened this issue Nov 4, 2024 · 0 comments
Open
1 task

Remove DBField casting when submitting via forms #11453

emteknetnz opened this issue Nov 4, 2024 · 0 comments

Comments

@emteknetnz
Copy link
Member

#11408 (comment) discovered that invalid DBField values are sometimes cast to a valid value before they are validated when submitted from a form. Instead what should happen is the value should not be cast and should instead cause a valid exception to be thrown

In that particular example the casting happening in DBBoolean::saveInto(). In was possible to get into this state by replacing the auto-scaffolded CheckboxField with a TextField instead, allows "this is not a boolean" to be the submitted value instead of 1 or 0.

Note that historically Silverstripe will often gracefully handle bad data rather than throw hard exceptions. This validation work is essentially the opposite way of handling bad data. Because of this, there may be some instances where this is too much of a change and we may need to soft things a little to reduce upgrade pain

Acceptance criteria

  • Validation exceptions are thrown by DBFields when invalid data is POSTed into a form submission endpoint
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant