Error when trying to add a Foreign Key dropdown to module form

edited March 2012 in Modules
Here's my code:

<?php if (!defined('BASEPATH')) exit('No direct script access allowed'); require_once(FUEL_PATH.'models/base_module_model.php'); class Invoices_model extends Base_module_model { public $foreign_keys = array('corporate_partner_id' => 'corporate_partners_model'); // Required Fields public $required = array('invoice_date', 'status', 'corporate_partner_id', 'amount_due'); function __construct() { parent::__construct('invoices'); } function list_items() { // Join to the Corporate Partners Table $this->db->join('corporate_partners', 'corporate_partners.id = invoices.corporate_partner_id', 'left'); // Select $this->db->select('invoices.id, invoices.id AS "Invoice Number", invoice_date, status, corporate_partners.name as "Corporate Partner", amount_due, transaction_id, payment_date, amount_paid'); $data = parent::list_items(); return $data; } } class Invoice_model extends Base_module_record { }

The $foreign_keys constraint causes my module form to display an error:

An Error Was Encountered Unable to locate the file: corporate_partners_model.php

Why is this occuring?

Comments

  • edited March 2012
    Is corporate_partners_model in an advanced module or up in application/models?

    If advanced, you'll need to specify the module like:
    public $foreign_keys = array('corporate_partner_id' => array('my_adv_module_name' => 'corporate_partners_model'));

    ^ Not tested that, it's what it looks like it needs looking at MY_Model::load_model()
  • edited March 2012
    That worked! Thanks very much! It is in an advanced module, so I replaced "my_adv_module_name" with "corporate_partners" and it worked.

    Suggestion: The modules section of the documentation could use a lot of expanding, since most of the questions I have are regarding custom modules in Fuel, and judging by the amount of questions on the forum tagged as "Modules" that is also further justification.
Sign In or Register to comment.