[eluser]Chicken's Egg[/eluser]
I am migrating my website from CodeIgniter 1.6.3 to 1.7.0. I'm trying to alter the code so the new form_validation library will be used, but I keep having problems repopulating my form.
I have a controller called Blog with a function called config(). This function in the controller shows a configuration screen - which shows the current configuration of my weblog - which I load from a database. The form gets populated as wished and changes I make are - after I post the form - stored correctly in the database. So far so good. However, after posting the form the form is empty! Set_value doesn't seem to set the values I posted.
My question is:
Is it forbidden to use set_value() in the controller as shown below?
This is a part of my controller:
Code:
// Configuration for this module
public function config()
{
// Log message
log_message('info', 'Controller:'. __METHOD__ . ' found and in use.');
// Load language
$this->lang->load($this->sModule.'/admin',$this->sLanguage);
// Set down validation rules
$config = array(
array(
'field' => 'sMeta_keywords',
'label' => 'conf_sMeta_keywords',
'rules' => 'trim|xss_clean|max_length[250]'
),
);
$this->form_validation->set_rules($config);
// If form is not send
if($_SERVER['REQUEST_METHOD'] != 'POST')
{
// Set language:
$this->blog_config->sTaal = $_SESSION['taal'];
// Receive already stored data;
$this->blog_config->config_read();
}
// Create form
$hidden = array(
'sTaal' => $_SESSION['taal'],
);
$fieldinfo = array(
'class' => 'form',
'accept-charset' => $this->data['meta_charset']
);
$form['form_start'] = form_open('admin/'.$this->sModule.'/config/',$fieldinfo,$hidden);
// Fieldset General start
$form['form_txt']['label'][] = form_fieldset($this->lang->line('conf_fieldset_general').':') . "\t</p>\n\t<p>\n\t\t" . '<div class="label">'. form_label($this->lang->line('conf_sMeta_keywords'), 'Meta_keyword') .'</div>';
$fieldinfo = array(
'name' => 'sMeta_keywords',
'id' => 'Meta_keyword',
'cols' => '50',
'rows' => '2',
'value' => set_value('sMeta_keywords', $this->blog_config->sMeta_keywords),
);
$form['form_txt']['field'][] = form_textarea($fieldinfo);
P.s.
The above is an abstract. Helpers, Libraries, Models and so on are loaded in the constructor.