It looks like you're new here. If you want to get involved, click one of these buttons!
I have a selections table
with:
ID
Package_id
Selection_Text
I have the public $foreign_keys = array('packages_id' => 'Packages_model');
Packages table is:
ID
Category_ID <--foreign key
Title
Package_text
Inside the model but the select box in the CMS is populating with
But the select box for the selections table is populating with the foreign key of the Packages table
I need the selections page to populate the foreign key select box with the Title of the Packages table with the ID of the packages table the value of the option. How can I do this?
Comments
In your model, you can overwrite the default behavior:
Thank you. I'll plug it in
This is my Selection_model
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
require_once(FUEL_PATH.'models/Base_module_model.php');
class Selections_model extends Base_module_model {
public $foreign_keys = array('packages_id' => 'Packages_model');
}
}
class Selection_model extends Base_module_record {
}
Still showing category_id in the selection box.
Try this or just changing
$val
to betitle
;I get the code. But Still not happening
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
require_once(FUEL_PATH.'models/Base_module_model.php');
class Selections_model extends Base_module_model {
public $foreign_keys = array('packages_id' => 'Packages_model');
}
}
class Selection_model extends Base_module_record {
}
If you change the title field to be the 2nd column in your table instead of the foreign key field does it work? Also, if you print out the value of $val, is it equal to 'title' before calling the parent::options_list(...)?
I moved the column with the ALTER command and it worked. Thank you.