well.. heres a post that will allow you to do a callback on read fields
as for removing / hiding fields in read state - it can be set using unset_read_fields
or setting up what fields u wana allow to be seen up while in read state
If you get stuck up anywhere .. feel free to contact back
Thank you for the reply i was trying to do your recommendation in that post but got lost so i tried other method. The qb_encoder_id was not visible in the read() view though but its ok because it can be seen on the grid. So this is my solution:
1.) I created a callback
$log_encoder = array(
"qb_id" => $primary_key,
"qb_encoder_id" => $this->session->userdata('username_id'), // sets encoder
"qb_published_id" => '0', // sets Published = No
"qb_PilotTest_id" => '0' // sets Pilot Tested = No
$this->db->update('tblqb',$log_encoder,array('qb_id' => $primary_key));
2.) Excluded the qb_encoder_id field in the $crud->fields() to remove it from the add/edit mode.
3.) Execute the call back using this:
This enables the setting of the default value of qb_encoder_id when the user adds a record.
4.) I created a code that executes when the user edits a record by using state:
$state = $crud->getState();
$state_info = $crud->getStateInfo();
if($state == 'edit')
//This updates the encoder of the question upon edit mode.
$primary_key = $state_info->primary_key;
$data = array(
'qb_encoder_id' => $username_id,
With this, I can assign the new encoder name once other users modifies the record.
I hope this helps other people with similar problem
Off this topic... i would like to ask you if it is possible to hide a visible field in add or edit mode upon selection of a value in a dropdown list? if it is... can you show a working example? I cannot figure out how to do it. The situation that I'm gonna use is: I'm creating a question bank. I have question types such as Multiple Choice, Fill in the Blanks, Essay etc. By default a Multiple Choice type of question has 4 options and the correct answer. But other types such as Fill in the Blanks have no option... they only have the question and the correct answer. I wanted to hide the 4 options during add or edit mode and set a value = "n/a" when the user selects a question type that is NOT Multiple Choice. Thank you in advance! God bless!