⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

Custom column value not showing in view/read?



Sonelal Singh

Sonelal Singh
  • profile picture
  • Member

Posted 02 July 2015 - 13:28 PM

HI,

 

I have calculated an age by date of birth(dob) field from my database and I am able to calculate age and display it on list page.

But on view/read page all fields value displaying as expected, except age. Below is my code - 

 

 $crud = new grocery_CRUD();
 $crud->set_theme('datatables');
 $crud->set_table('ci_users');
        
$crud->set_subject('User');
$crud->required_fields('empcode', 'firstname', 'lastname', 'email', 'phone', 'password', 'department', 'role', 'status');
$crud->columns('empcode', 'firstname','lastname','email','phone','department', 'role', 'status', 'designation', 'team','Tenure','supervisor','created_date');
$crud->fields('empcode', 'firstname','lastname','email','phone','department', 'role', 'status', 'designation', 'team','supervisor','Tenure');
                
                
$crud->callback_column('created_date', array($this, 'callback_date'));
                
 
//this field I want to display on my read/view page 
$crud->callback_column('Tenure', array($this, 'callback_calculate_tenure'));
                
        
// Field Setup
$crud->change_field_type('password','password');
 
// Relations
 $crud->set_relation('supervisor','ci_users','{firstname} {lastname}');
$crud->set_relation('department','ci_departments','department');
$crud->set_relation('role','ci_roles','roles');
$crud->set_relation('status','ci_status','status');
$crud->set_relation('designation','ci_designations','designation');
$crud->set_relation('team','ci_teams','team');
$crud->unique_fields('email');
$crud->set_rules('email', 'Email', 'required|valid_email');
 
 
 $output['output'] = $crud->render();
 $output['title'] = "abc";
 $output['userrole'] = $this->session->userdata('role');
 $output['pagehead'] = "User Management";
$output['output'] = $crud->render();

 

So what is wrong with my code,why age is not showing on read page.

Note:- I am using version 1.4.2

 


Paul Savostin

Paul Savostin
  • profile picture
  • Member

Posted 03 July 2015 - 09:29 AM

Hi! Have you read docs on the GC site?
 

"//this field I want to display on my read/view page 
$crud->callback_column('Tenure', array($this, 'callback_calculate_tenure'));"  - this is for list view, for read state you have to use callback_field, where you can find out state - read, insert, edit ... e.t.c.