a form validation issue |
So it seems in 3.1 there was a change to the form validation library that re-orders the rules putting callbacks to be run first.
Quote:Prepare rules I am not sure what the reasoning behind this was but it appears to be fairly annoying. Could just comment out the re-ordering but there must have been a reason this was done. Perhaps someone from the CI team could tell us why this was. I am going to head over to github to see if I can find a reason behind it, although to me it seems the rules should be applied in the order I put them. Best wishes, Paul.
I can't find it on github. But to revert the order so callbacks are called last, in the form_validation library in the system libraries change line 547:
from: PHP Code: return array_merge($callbacks, $new_rules); to: PHP Code: return array_merge($new_rules, $callbacks); And sanity is returned. However as a disclaimer, I do not know if there are any knock on affects, in that the orders were altered for some reason, and I do not know the reason. Best wishes, Paul. PS LOL I noticed only just now that you mentioned this in your 2nd post, which I must have glibly discarded at that time as I thought I was on 3.1 but was on 3.06. Quote:I checked the system/libraries/Form_validation.php file(CI 3.1.0), I was wondering is it because of the _prepare_rules function? So, the callback function and rule's order was change.
Hi Paul
Did you ever get a permanent resolution to this issue? I am new to CI and am also facing this with an application I have migrated from CI 2.1.4 to 3.1.3. I have made the change you suggested to line 547 and all is working ok now but I don't like changing the core files and would like a solution that did not require changing core files. If an extension could be added in the application\libraries folder as an alternative this will not get overwritten by core updates. Thanks Philip Code: class MY_Form_validation extends CI_Form_validation
Hi Narf
Just tested your code, and it worked great for me on 3.1.3. Thanks for your help Philip
Hi Guys,
I give thanks to Narf too. I had the same issue - https://forum.codeigniter.com/thread-67280.html Mr Lister.
Paul and Narf, thank you.
You guys help me a lot, and the solution is great. Thanks again. |
Welcome Guest, Not a member yet? Register Sign In |