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
2 tasks
emteknetnz opened this issue Nov 4, 2024 · 0 comments
Open
2 tasks

Remove DBField casting when submitting via forms #11453

emteknetnz opened this issue Nov 4, 2024 · 0 comments

Comments

@emteknetnz
Copy link
Member

emteknetnz commented Nov 4, 2024

#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
  • Validation errors are not thrown when valid values are entered into formfields (e.g. using a TextField with a DBInt should not result in validation errors saying "value must not be a string")
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