Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make it compatible with Vizy Plugin #383

Open
luizboaretto opened this issue Nov 21, 2023 · 1 comment
Open

Make it compatible with Vizy Plugin #383

luizboaretto opened this issue Nov 21, 2023 · 1 comment
Labels

Comments

@luizboaretto
Copy link

Using this field inside Vizy plugin, I get this error:

SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'ownerId' cannot be null
The SQL being executed was: INSERT INTO `maps` (`ownerId`, `ownerSiteId`, `fieldId`, `lat`, `lng`, `dateCreated`, `dateUpdated`, `uid`) VALUES (NULL, 1, 15, '-9.6476843', '-35.7339264', '2023-11-21 21:57:21', '2023-11-21 21:57:21', '9118b2a0-2cbe-4433-a20d-032d70233d46')
@engram-design
Copy link

engram-design commented Nov 24, 2023

I'm not fully across why Simplemap has its own database table for it's content, but that's the cause of the issue. It assumes that the element that "owns" the field has an ID, which in this case is a fake Block element for Vizy, because Vizy Blocks aren't elements. When it tries to save its content to its own maps table, recording the owner ID, siteId, etc - it won't work, as there is no saved element record for a Vizy block.

One thing that does work is to just not save the record unless there's valid element data.

$record->lat = $map->lat;
$record->lng = $map->lng;
$record->save(false);

Changing to:

$record->lat = $map->lat;
$record->lng = $map->lng;

if (!$record->ownerId) {
    return;
}

$record->save(false);

But I'm not sure the ramifications of doing so. The field value stores fine, as the value is serialized in Vizy's content.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants