[eluser]Phil Sturgeon[/eluser]
Hey, not entirely sure whats going on here. Its the first time I have properly used the validation class on a form that has database entries in it to begin with, and im not having alot of fun.
You can see I have defined 5 fields names, they are the only ones with ruels and therefore I imagine the only ones that need to be named. It seems that when I add information, it will save it fine but the variables for those 5 named in $fields will not be loaded. They are in db, just dont show.
When I comment out set_fields() they show fine.
Code:
$rules = array(
'user_firstname' => 'trim|required',
'user_lastname' => 'trim|required',
'personal_url' => 'trim|max_length[100]',
'birthday' => 'trim',
'location' => 'trim',
'occupation' => 'trim|xss_clean',
'interests' => 'trim|xss_clean',
'aol_im' => 'trim',
'icq_number' => 'trim',
'yahoo_im' => 'trim',
'msn_im' => 'trim|valid_email',
'gtalk_im' => 'trim|valid_email',
'about_me' => 'trim'
);
$fields = array(
'user_firstname' => $this->lang->line('first_name'),
'user_lastname' => $this->lang->line('last_name'),
'personal_url' => $this->lang->line('personal_url'),
'msn_im' => $this->lang->line('msn_im'),
'gtalk_im' => $this->lang->line('gtalk_im')
);
$this->validation->set_rules($rules);
$this->validation->set_fields($fields);
if ($this->validation->run() === FALSE):
// Just using the rules array to get a list of field names
foreach(array_keys($rules) as $field):
$this->data[$field] = (isset($this->validation->$field)) ? $this->validation->$field : $this->user_model->getPropFromID($field);
endforeach;
blablabla...
So this brings me to my question, WTF?
I am a noob with the validation class so feel free to laugh untill I bleed if its something silly.