Skip to main content
added 189 characters in body
Source Link
4uk4
  • 101.7k
  • 7
  • 173
  • 217

Form validation checks the user input before it gets submitted. The submitted values don't necessarily go into the database, they can be used for other things. Presave can check values before they are stored in the database. The values don't need to come from a form, they can be generated by other code. So those two things are not connected.

TLDR: If you want to validate a form, you have to use form validation. Presave doesn't know anything about forms and can't help. It is no problem to double check in presave, then you with thatprevent wrong values to enter into the database from any code. But if you want to give the user a feedback in the form, use form validation. In presave you can only throw an exception after submit.

Form validation checks the user input before it gets submitted. The submitted values don't necessarily go into the database, they can be used for other things. Presave can check values before they are stored in the database. The values don't need to come from a form, they can be generated by other code. So those two things are not connected.

TLDR: If you want to validate a form, you have to use form validation. Presave doesn't know anything about forms and can't help you with that.

Form validation checks the user input before it gets submitted. The submitted values don't necessarily go into the database, they can be used for other things. Presave can check values before they are stored in the database. The values don't need to come from a form, they can be generated by other code. So those two things are not connected.

If you want to validate a form, you have to use form validation. Presave doesn't know about forms. It is no problem to double check in presave, then you prevent wrong values to enter into the database from any code. But if you want to give the user a feedback in the form, use form validation. In presave you can only throw an exception after submit.

Source Link
4uk4
  • 101.7k
  • 7
  • 173
  • 217

Form validation checks the user input before it gets submitted. The submitted values don't necessarily go into the database, they can be used for other things. Presave can check values before they are stored in the database. The values don't need to come from a form, they can be generated by other code. So those two things are not connected.

TLDR: If you want to validate a form, you have to use form validation. Presave doesn't know anything about forms and can't help you with that.