Thanks Amit Shah for this explanation. I could make it work !
Employees example : (check 'Firrelli Julie' at top left)
[attachment=762:replace_form_header_with_value.png]
public function employees_show_name()
{
$crud = new grocery_CRUD();
$crud->set_theme('datatables');
$crud->set_table('employees');
$crud->set_relation('officeCode','offices','city');
$crud->display_as('officeCode','Office City');
$crud->set_subject(''); // ============================ must be empty not to appear in form header
//
$crud->columns('lastName','firstName','email','officeCode','country_office');
//
// ================= Workaround to show the name of the employee in the header of the form (in edit mode)
$crud_mode = $crud->getState();// Get state
$infos = $crud->getStateInfo();
if ($crud_mode == 'edit') {
$fields = $this->_get_fields($infos->primary_key);
$crud->set_lang_string('form_edit',$fields->lastName . " " . $fields->firstName);// The name takes place of the GC message
}
// ================ End of workaround
//
$crud->required_fields('lastName');
$crud->set_field_upload('file_url','assets/uploads/files');
$output = $crud->render();
$this->_example_output($output);
}
// Required function to make it work
protected function _get_fields($id_employee)
{
$select = "SELECT * FROM employees WHERE employeeNumber=$id_employee";
$query = $this->db->query($select);
if ($query->num_rows() == 1) {
return $query->row();
} else {
return null;
}
}
The first name and the last name are displayed in the header of the form instead of "Edit Employee".
Ciao