[eluser]absurdparadox[/eluser]
To preface this, I'm quite a php noob (with 8 years development experience in other languages). I'm trying to figure out how to preset my validation variables from a query for a form that is an Add/Edit form. So far what I have is the following:
Code:
if (empty($_POST))
{
$row = $this->getuser($id);
$this->validation->id = $row->id;
$this->validation->username = $row->username;
$this->validation->email = $row->email;
$this->validation->firstname = $row->firstname;
$this->validation->lastname = $row->lastname;
$this->validation->company = $row->company;
$this->validation->address1 = $row->address1;
$this->validation->address2 = $row->address2;
$this->validation->city = $row->city;
$this->validation->state = $row->state;
$this->validation->zip = $row->zip;
$this->validation->wphone = $row->wphone;
$this->validation->hphone = $row->hphone;
$this->validation->mphone = $row->mphone;
$this->validation->status = $row->status;
$this->validation->roleid = $row->roleid;
}
What I would like to do is use the $fields array set for the set_fields() function to set these progamatically, example
Code:
while( $element = each( $fields ) )
{
$fieldname = $element['key'];
$this->validation->$fieldname = $row->$fieldname;
}
Not sure how to do this in PHP though... I found stuff about using double $$ for variable of variables, but I can't seem to find anything that works. Can someone give me a hand?