Sever
Sever

Reputation: 2636

Grocery crud set_relation

$crud->set_relation('seo_url', 'db_projects','seo');

On insert/update crud add id (primary key ) from db_projects to seo_url field. How can I add seo from db_projects not id (primary key) to seo_url field?

Upvotes: 1

Views: 1600

Answers (1)

John Skoubourdis
John Skoubourdis

Reputation: 3259

For this situation I think the only solution is to actually create a custom dropdown list with field_type method. So in your case you will have:

$seo_results = array();
foreach ($this->db->get('db_projects')->result() as $row) {
    $seo_results[$row->seo] = $row->seo;
} 
$crud->field_type('seo_url', 'dropdown', $seo_results);

Upvotes: 2

Related Questions