[eluser]Jason Tan Boon Teck[/eluser]
I found that somehow, set_value() hangs onto the values retrieved from POST, ignoring any reassignments in the controller. So I got it to work by subsequently pushing the new values back to the POST array and pulling back the values from this updated array.
Is this a bug?
[quote author="Jason Tan" date="1290878744"]
Controller ehr_individual.php snippets:
Code:
$data['init_birth_date'] = $this->input->post('birth_date');
$data['init_birth_date_estimate'] = $this->input->post('birth_date_estimate');
$data['init_age'] = $this->input->post('age');
...
// echoing from controller just for debugging purposes
if(($data['init_birth_date_estimate'] == "TRUE") && ($data['init_age'] > 0)){
echo "Compute birth date based on age";
$age = "-".floor($data['init_age']*365.2425)." days";
$data['init_birth_date'] = date("Y-m-d", strtotime($age));
echo "<br />data['init_age']=".$data['init_age']." <br />data[init_birth_date]=".$data['init_birth_date']." <br />age=".$age;
} elseif(($data['init_birth_date_estimate'] == "FALSE") && (!empty($data['init_birth_date']))) {
echo "Compute age based on birth date";
$data['init_age'] = round((time()-strtotime($data['init_birth_date']))/(60*60*24*365.2425),1);
echo "<br />data['init_age']=".$data['init_age']." <br />data[init_birth_date]=".$data['init_birth_date'];
} else {
echo "E R R O R";
}
[/quote]
Code:
$_POST['birth_date'] = $data['init_birth_date'];
$data['init_birth_date'] = $_POST['birth_date'];
$_POST['age'] = $data['init_age'];
$data['init_age'] = $_POST['age'];
...
$this->load->vars($data);