Welcome Guest, Not a member yet? Register   Sign In
Possible bug in set_value method of Form Validation Library
#1

[eluser]everdaniel[/eluser]
Hi Guys!

I posted a comment about this in the forums yesterday and I think I found what's wrong with it a few hours ago, basically, my problem is:

I'm trying to re-populate a form with data from a db using the set_value() function, but this function only works when I enter the edit page for the first time (following a link), it doesn't work if I enter the edit page clicking on a submit button.

Reason is, if there is no data in the $_POST var, the fields that I define using set_rules() are not set, and the set_value() works. The set_value() only returns the default data if the field hasn't been set. Since I'm entering the page using a submit button, there is data in the $_POST var, the fields are set using the set_rules() and the form_validation returns the postdata he has for that field (which is empty, since I'm coming from another different page).

For better clarification, in line 732 in Form_validation.php file we have:

Code:
if ( ! isset($this->_field_data[$field]))
{
  return $default;
}

if the field is not set, the default data is returned, so if I change this to:

Code:
if ( ! isset($this->_field_data[$field]['postdata']))
{
  return $default;
}

then it works and the default data is set in the form fields.

Can anyone here confirm this? if it's a bug or it's just me? Tongue

Attached are files to test this.


Messages In This Thread
Possible bug in set_value method of Form Validation Library - by El Forum - 01-16-2009, 08:32 AM



Theme © iAndrew 2016 - Forum software by © MyBB