⚠ 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

Error when using both set_relation_n_n and set_relation to the same table.



jjwdesign
  • profile picture
  • Member

Posted 08 May 2013 - 20:07 PM

Has anyone seen this error when trying to use both set_relation_n_n() and set_relation() to the same table?

 

I've got a 1-to-many and a many-to-many relationship to a 'contacts' table that I need to define. The many-to-many is for partners contacts and the 1-to-many is for a related vendor.

 

$crud->set_relation('vendor_id', 'contacts', '{contacts.first_name} {contacts.last_name} ({contacts.company})');

$crud->set_relation_n_n('contacts', 'collections_contacts', 'contacts', 'collection_id', 'contact_id', '{contacts.first_name} {contacts.last_name} ({contacts.company})', 'priority');

 

The column names seem to be prefixed with the table name and the "as" name. Note: j96b1f972.contacts.first_name

 

Error Number: 1054

Unknown column 'j96b1f972.contacts.first_name' in 'field list'

SELECT `collections`.*, CONCAT('', COALESCE(j96b1f972.contacts.first_name, ''), ' ', COALESCE(j96b1f972.contacts.last_name, ''), ' (', COALESCE(j96b1f972.contacts.company, ''), ')') as s96b1f972 FROM (`collections`) LEFT JOIN `contacts` as j96b1f972 ON `j96b1f972`.`id` = `collections`.`vendor_id`

I assume I could just create my own custom field dropdown for the "vendor_id" field as it's not as special as the many-to-many relationship. Any suggestions?

 


davidoster
  • profile picture
  • Member

Posted 08 May 2013 - 21:31 PM

Interesting. I will try to reproduce it to see what happens.

But if you can get away with using a custom dropdown do it.

Use the field_type function.