Unable to get value of foreign key dropdown in simple module
Hi Guys,
I am developing a site with Fuel CMS and so far, its been awesome except for this stumbling block.. I have created several simple modules for basic database interactions.. In one of my modules, I use a foreign key so which automatically displays a select dropdown field on my create/edit page for my module... But, the problem is, I cant get the value from the dropdown. Below is my code snippet contained in the on_before_validate function -
$values['package_name'] = $values['package_id'] ;
where package_id is the id value for the foreign key dropdown.... Using inspect element on my browser, I can see the values for each dropdown options but somehow, I just cant seem to get the value in PHP.. It returns an undefined index error..
Pls, any help with be greatly appreciated..
Comments
public $foreign_keys = array('package_id' => 'packages_model');
Then in your on_before_validate method you have something like:
function on_before_validate($values) { $values['package_name'] = $values['package_id'] ; return $values; }
If so, is the package_id showing up in the $_POST variable (you could test it in the on_before_validate method)?
function on_before_validate($values){
//$values['product_package_id'] = $values['package_id'] ;
if(isset($values['package_id'] )){
$values['package_name'] = $values['package_id'] ;
}
return $values;
}
I had to test with the isset function just to turn off the undefined index error...Still not getting the value
Thanks for your response!!
Cheers and big ups to a awesome CMS....