Reference #1126 and #1121
Just as a quick thought, could this not be run after all execution in run()? It was being run pretty high up before, but surely it could be run RIGHT at the end?
I think that the problem with that is that it clears all the validation error messages...so if you try get _error_array() or $_error_messages after run() they will be empty.
Jup tested that yesterday... Does not show the errors...
At the start of run():
$this->_error_array = array();
$this->_error_messages = array();
$this->error_string = '';
At the end of run():
$this->_field_data = array();
$this->_config_rules = array();
@IT-Can Can you have a quick test to see if that works please?
okido, couple of minutes....
Ok seems to work (in my case)... I am getting all messages like before...
OK, cool, thanks. Will adjust accordingly.
Thanks for the help @IT-Can
Hopefully this is good to go now.
@JonoB thanks for the quick response ;-)
not sure if related but form_error('field') returns nothing while validation_errors() works
@quasiperfect Which code are you running this on? Can you try the suggested changes in #1127 (comment) please?
@JonoB i tried with the form_validation file from your git
i verified and it contains the code from the comment and after some testing i think $this->_field_data = array() (at the end of run) is the problem because it empties the array so when the helper calls the error function it failes at the first condition the
$this->_field_data[$field] is not set
so to fix in function error we should use $this->_error_array[$field] insted of $this->_field_data[$field]['error']
correct me if i'm wrong
not tested but i'm sure will be problems with set_value and other form helper methods that relay on $this->_field_data
Edit: yeap i was right
Ok, I can confirm that set_value is not working correctly with the latest changes...
I have an email-field, requires a valid email, but with the latest changes it gives an error that the email is not correct, but set_value shows the original value instead of the posted value....
@JonoB Is this fixable?
Bah ok, looks like we just can't reset things. Reliance on the singleton is just too much. We'll just have to accept that if you do two forms in one page you need to reset it.
Unfortunately, without a major re-write of form_validation library, we will have to accept that user will have to manually clear it.
@philsturgeon Is it possible to merge in the first pull request (JonoB@8af2fdf) in this thread and not the second?