⚠ 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

auto generated field but custom data



Sohibe Elmigo
  • profile picture
  • Member

Posted 13 January 2013 - 10:33 AM

Hello everyone

can you please tell me how to edit data inside auto generated field (type: select "ComboBox") without changing html (design)

means i don't want to use my own html i want to use the same auto generated field html but custom data.

Thank you


i'll show you what i want to do exactly :

please take a look at db.png first


$crud->set_table('employee');

$crud->set_relation('BankBranch_idBankBranch', 'BankBranch', '{Bank_idBank} / {BankBranchName}');



this code will show the id of the bank but i want the name of the bank

i managed to make a callback to get the bankName / BankBranchName but without the auto field html (design)

Thank you again

deib97
  • profile picture
  • Member

Posted 01 April 2013 - 04:36 AM

u can use change_field_type with enum on mysql


davidoster
  • profile picture
  • Member

Posted 01 April 2013 - 09:05 AM

u can use change_field_type with enum on mysql

 

How this will help [member=deib97]?

 

Because you need information from another table there is no way from a set_relation to get data from multiple tables (unless you use set_relation_n_n).

 

This can be done by using a custom model,

 

check this sample code:

 

/* model */
function get_activities($table)
{
	$this->db->select('id, year, description');
	$this->db->order_by('id desc');
	return $this->db->get($table);
}


/* controller */
$this->load->model('itemmodel');
$activities = $this->itemmodel->get_activities("activities");
foreach ($activities->result() as $row)
{
	$myarray[$row->id] .= $row->description;
}
$this->grocery_crud->field_type('interest_for','multiselect',$myarray);

deib97
  • profile picture
  • Member

Posted 01 April 2013 - 09:18 AM

thanks davidoster, i will try with your code. :)