Welcome Guest, Not a member yet? Register   Sign In
Exceptions exceptions...
#7

(This post was last modified: 04-20-2020, 07:09 AM by Gary.)

Did you try it with only TWO parameters, as what the framework's function definition appears to call for?

As in:
$validation->setError('field_name_where_error_will_show', 'custom_message_and_user_insults_here');

As an aside, using setError will overwrite any existing error messages in previous validation calls... and is purely intended as an easy way to inject error messages into the program flow to use one's existing error display. So, without my having followed though/checked what's happening in the framework validation code, to be safe, it is best applied as the last validation-related call in the controller before the error display is invoked in the view.

Looking at your code, it looks like if the imageException is called, it will overwrite all of the other validations... it probably needs to be done in two steps (because of this overwriting, not appending to):
1) general validation of the upload -> display these validation errors in the view
2) once general validation all clear, process the file -> catch these exceptions -> use setError to inject these into the validation error message array -> display validation errors (which now contains the injected message) in the view
Reply


Messages In This Thread
Exceptions exceptions... - by Gary - 04-17-2020, 07:07 AM
RE: Exceptions exceptions... - by Leo - 04-19-2020, 02:08 PM
RE: Exceptions exceptions... - by Gary - 04-19-2020, 04:20 PM
RE: Exceptions exceptions... - by Leo - 04-20-2020, 12:12 AM
RE: Exceptions exceptions... - by Gary - 04-20-2020, 02:56 AM
RE: Exceptions exceptions... - by Leo - 04-20-2020, 06:05 AM
RE: Exceptions exceptions... - by Gary - 04-20-2020, 06:52 AM
RE: Exceptions exceptions... - by Leo - 04-20-2020, 10:31 AM
RE: Exceptions exceptions... - by Gary - 04-20-2020, 01:51 PM



Theme © iAndrew 2016 - Forum software by © MyBB