Well I'm still kinda new to GC as this is my second post.
I've been developping at a speed I have never developped before. (I'm just a hobbyist programmer)
After getting to know the API i found that there where things I could not do with the API, luckely there is the forum and I found solutions/workarounds/hacks for most of my issues.
There was one thing I saw asked a lot in the forum that got answers but no solution/workaround (I have not read the entire forum (yet!!) so excuse me if the workaround was already demonstrated)
Maybe the solution is obvious to most but for me it took a while to figure it out.
The Issue:
You have a table that has a user_added field and in this field you store the id of the user who added the record.
In some cases you want to display the name of the user who added the record in the list view.
Well then you need to use set_relation function to get the name of the user who added the record from the users table for displaying in the list view.
$crud->set_relation('user_added','users','username');
You also want to hide the field user_added on the add form because you want to use session data to set it to the logged in user.
$crud->field_type('user_added','hidden',$this->session->id_user_added);
The above conflicts in GC, resulting in showing a textbox for the user_added field on the add form
To get around this limitation I just added this in the controller.
if($this->uri->segment(3)!='add'){ $crud->set_relation('user_added','users','username'); }
No idea why it works, but I'm guessing that this way the set_relation function only gets executed when not in add view, meaning no conflict with the hidden field on the add form.
(Possibly u need to adjust the segment number, for the edit form I exclude the user_added field with edit_fields function)
using:
codeigniter 3.+
GC 1.5.7
Bootstrap theme v3 (totaly worth buying)