Welcome Guest, Not a member yet? Register   Sign In
set_value() Does Not Maintain the Value
#1

[eluser]fjamal[/eluser]
Set value does not maintain the field value when i get validation errors.

***View***:

Code:
echo form_input('post_title', set_value('post_title'));

Controller:

Code:
if ($this->form_validation->run('post_ad') == FALSE)
{
    set_temporary_msg(validation_errors('<div>', '</div>'));  
}

Helper:

Code:
function set_temporary_msg($msg, $target_location = '')
{
$CI =& get_instance();
$CI->session->set_flashdata('temp_msg', $msg);
redirect($target_location);
}

function get_temporary_msg() {

$CI =& get_instance();
echo $CI->session->flashdata('temp_msg');

}

If some input are invalid, set_temporary_msg() is called.
At the top of the ***View*** page, i echo get_temporary_msg();

Error messages and redirection work fine, but i lose all set_value(). Any idea how to solve this issue?
#2

[eluser]Aken[/eluser]
set_value() checks the $_POST array for matching fields. When you redirect, you lose all POST data.




Theme © iAndrew 2016 - Forum software by © MyBB