Thank for your quick answer
The problème I have is that when I put
$crud->field_type('field_name','readonly');
I can't update that field in the database.
- Creation date : I have the default value CURRENT_TIMESTAMP
in the database
But when I Update my record I want to update the today's date in the database without having an input field in the form
here is my code
$crud = new grocery_CRUD();
$crud->set_theme('t17');
$crud->set_table('gp_user');
$crud->fields('uscode','usnom','uspass','usdatcrt','usdatupd');
$crud->display_as('uscode','Code utilisateur');
$crud->display_as('usnom','Nom');
$crud->columns('uscode','usnom');
$crud->change_field_type('uspass','password');
//$crud->field_type('usdatcrt','readonly');
/* if ($operation == 'edit' || $operation == 'update' || $operation == 'update_validation') {
$crud->field_type('usdatusr','readonly');
}*/
$crud->field_type('usdatupd','readonly');
$crud->field_type('usdatcrt','readonly');
$crud->callback_before_update(array($this,'beforeupdate'));
$crud->callback_edit_field('uspass',array($this,'set_password_input_to_empty'));
$crud->callback_add_field('uspass',array($this,'set_password_input_to_empty'));
$output = $crud->render();
$this->_example_output($output);
}
function set_password_input_to_empty() {
return "<input type='password' name='password' value='' />";
}
function beforeupdate($post_array, $primary_key = null)
{
if(!empty($post_array['uspass']))
{
$post_array['uspass'] = md5($post_array['uspass']);
}
else
{
unset($post_array['unpass']);
}
$post_array['usdatupd'] = date('Y-m-d');
return $post_array;
}
The field usdatupd
is my update date is not updated when I have
$crud->field_type('usdatcrt','readonly');
it works well when I comment this line