Outstanding answer from Dafa! That's perfect! Thank you.
For the original poster:
Clearly, the way that you are performing form validation is a little bit different to how most of the rest of us would do validation.
However, even though I personally am not a fan of coding that way, I do accept that it's reasonable to submit a form to 'self' (i.e., the current URL). So, if your issue is that validation doesn't work if submitting to self on the homepage then that is a VERY unusual situation. It's certainly the first time I've heard of anybody trying that.
Nevertheless, your issue is legitimate. Nobody should be forced to code like me.
So, whilst Dafa's answer is perfect I'll take a little time to think about whether this requires any changes to the framework.
As always, I welcome any advice that I can get from you folks.
Thanks to everyone for helping with this thread.
4 years ago
#11
4 years ago
#12
First of all big thank you to DaFa for doing a RCA and providing a solution promptly. Personally i don't want to mess up the framework engine files so currently i have changed the endpoint for a POST request.
To the DC:
IMO issue like this can put someone in a disastrous situation if enough testing is not done before going live. Either we should update a documentation to inform developers about this behavior or changes should be made to framework(for the shake of uniformity).
To the DC:
IMO issue like this can put someone in a disastrous situation if enough testing is not done before going live. Either we should update a documentation to inform developers about this behavior or changes should be made to framework(for the shake of uniformity).
4 years ago
#13
So, to clarify what the issue was here.
The validations did not work because the form was on the index page?
Therefore no segment 3?
Thanks,
Dan
The validations did not work because the form was on the index page?
Therefore no segment 3?
Thanks,
Dan
4 years ago
#14
Hi Dan,
The issue is the validation helper looks for a module name at segment 1, and because eleetgeek had his form calling itself from the base url level, segment 1 wasn't there to be found on the url. The code I added tests for null, and then pulls in the default module name from config.php so the framework then knows which module is asking for the callback_
Edit:
So in other words, the validation callback_ works from any controllers index, just not the default module where the current URL is equal to the BASE_URL
Eleetgeek, could you please close off this thread when you get a moment?
The issue is the validation helper looks for a module name at segment 1, and because eleetgeek had his form calling itself from the base url level, segment 1 wasn't there to be found on the url. The code I added tests for null, and then pulls in the default module name from config.php so the framework then knows which module is asking for the callback_
Edit:
So in other words, the validation callback_ works from any controllers index, just not the default module where the current URL is equal to the BASE_URL
Eleetgeek, could you please close off this thread when you get a moment?