Jump to content


infinitesunrise

Member Since 10 Oct 2017
Offline Last Active Jan 06 2020 11:53 PM
-----

Topics I've Started

set_relation_n_n doesn't work with custom callbacks

03 January 2020 - 04:54 PM

I have a database that uses a custom notes system quite extensively for leaving custom comments on arbitrary records: The database has a "notes" table with columns for note id, table name, and note contents - I then utilize Grocery CRUD's callback functions to allow my users to create an unlimited number of custom notes for any records in supported tables upon record insert or update, and I also use delete callbacks to clean up associated notes. It's been working quite well so far, we're leaving notes on everything!

 

However I was recently asked to add an n-n relationship between two tables. I said no problem, we can do that with set_relation_n_n. But upon going to implement the relation I am getting "An error occurred on saving" when trying to insert, and a success message when updating but without any actual updates happening. I suspected that set_relation_n_n uses it's own callbacks to work it's magic, so out of curiosity I commented out all of my own note-related callbacks and tada! The relation started working. Problem: I need both the notes and the relation to work at the same time.

 

Am I correct that there is an undocumented incompatibility between callbacks and set_relation_n_n? And if so is there any known workaround? Thanks in advance for any and all help.