Ad

OctoberCMS - Builder Plugin: Prevent The Partial From Being Called If The Current Record Has Not Yet Been Created

I use the builder plugin and a partial in it. If I enter data in the partial without saving the actual record first, I get an sql error (SQLState [23000]: Integrity violation constraint: 1048 column 'item_id' cannot be null...).

How can I let the partial check if the corresponding record is already there? (or how can I prevent the partial from being called if the current record has not yet been created, i.e. saved?).

Supplementary information: The attached pictures illustrate the basic problem.

First I integrate the partial control into my model. Used element from the control list of the Builder Pluginenter image description here

Then I create the required relationships etc. on the code level. Finally I can access the partial in my new plugin.

Access to the embedded partial.

And this is where the problem arises. I must first create the record under General (i.e. enter data there and click on Save.). Otherwise I get the above error message.

I'm looking for an option, which checks whether the click on Create Translations first checks whether the corresponding record already exists.

Ad

Answer

The problem is solved.

The reason for the Integrity violation constraint was that the foreign key to the item ID (item table) must be nullable in the translation table.

However, this results in the problem that an item can be created with a translation but without the corresponding item data.

Ad
source: stackoverflow.com
Ad