Hello,
I have a problem evaluating a condition. I have if((empty($post_array['Date_Deb'])) && ($post_array['Etat'] == '3')) as condition and Date_Deb is being updated even if Date_Deb is NOT empty.
The second part of the condition is evaluated correctly. If Etat is not equal to 3, Date_Deb is not updated.
You can see my code below.
Note that Date_Deb is set as a read only field but removing that constraint don't change anything. It seems GC is seeing $post_array['Date_Deb'] on update even if it had been previously filled in using the function.
Can you tell me what is wrong please?
function st3() {
$crud = new grocery_CRUD();
$crud->set_table('t3');
$crud->columns('ID','Nom_agt','Date_Rem','Date_Deb', 'Etat');
$crud->set_subject('T3');
$crud->set_relation('Etat','etat_debriefe','etat');
$crud->set_relation('Nom_agt','agents','agt');
$crud->fields('Nom_agt','Date_Rem','Date_Deb', 'Etat');
$crud->edit_fields('Nom_agt','Date_Deb', 'Etat');
$crud->field_type('Date_Deb', 'readonly');
$crud->callback_after_update(array($this, 'update_date_debriefe'));
$output = $crud->render();
$this->_example_output($output);
}
function update_date_debriefe($post_array,$primary_key)
{
if((empty($post_array['Date_Deb'])) && ($post_array['Etat'] == '3')) {
$date_debriefe = array("ID" => $primary_key,"Date_Deb" => date('2013-07-01'));
$this->db->update('t3',$date_debriefe,array('ID' => $primary_key));
return true;
}
}
