verbb / super-table

Super-charge your Craft workflow using Super Table.
MIT License
316 stars 47 forks source link

Can't save new entries with a static Super Table Field on it #518

Closed davidhellmann closed 1 year ago

davidhellmann commented 1 year ago

Describe the bug

I did some updates to CraftCMS 4.4.10 and Supertable 3.0.8.1

When I create a new entry where a Super Table field is attached (min: 1, max: 1, Static Field: True), then I can't save the entry. If I change something within the Super Table field I can save the entry.

Within the logfile I found this:

2023-05-11 09:28:02 [web.INFO] [craft\services\Elements::_saveElementInternal] Element not saved due to validation error: Array
(
    [dtmMetaMisc] => Array
        (
            [0] => Meta Misc cannot be blank.
            [1] => Meta Misc should contain at least 1 block.
        )

)

Two screenshots: CleanShot 2023-05-11 at 11 31 09

CleanShot 2023-05-11 at 11 24 23

Steps to reproduce

  1. Create a new entry with the Super table field
  2. Hit save

Craft CMS version

4.4.10

Plugin version

3.0.8.1

Multi-site?

Yes

Additional context

No response

davidhellmann commented 1 year ago

Not sure if there is a relation to this issue: https://github.com/craftcms/cms/issues/13155

davidhellmann commented 1 year ago

Test it also with other fields on the Entries, same problem: CleanShot 2023-05-11 at 11 35 29

davidhellmann commented 1 year ago

Updated to the latest versions, still the same problem :/

davidhellmann commented 1 year ago

@brandonkelly is that maybe something related to matrix? When I'm right, SuperTable is using some Matrix Stuff itself under the hood?

brandonkelly commented 1 year ago

@davidhellmann Super Table reproduces a lot of the same code as Matrix, but it’s separate.

Are you able to reproduce the same bug using a static Matrix field? (were Min and Max rows are each set to the same number)

davidhellmann commented 1 year ago

@brandonkelly yep. I changed the settings from static to min 1 / max 1, but I got the same result. I'll start the update process from scratch next week and try to update just CraftCMS, and if that works, I'll update super-table, and then we'll know where the problem comes from. But I think it's more an super-table thing. I'll give an update if I have further information.

ttempleton commented 1 year ago

I applied the Matrix bug fix from https://github.com/craftcms/cms/pull/12983 to Super Table locally and that seems to resolve it.

davidhellmann commented 1 year ago

@engram-design can you have a look, would be great :)

davidhellmann commented 1 year ago

I applied the Matrix bug fix from craftcms/cms#12983 to Super Table locally and that seems to resolve it.

Yep that works here too.

        // Safe to create the default blocks?
        if ($createDefaultBlocks || $this->staticField  && count($value) < $this->minRows) {
            $blockTypeJs = Json::encode($this->getBlockTypes()[0]);

            $view->setInitialDeltaValue($this->handle, null);
            $minRows = ($this->staticField) ? 1 : $this->minRows;

            for ($i = count($value); $i < $minRows; $i++) {
                $js .= "\nsuperTableInput.addRow({$blockTypeJs});";
            }
        }

Sorry for ping you again @engram-design, but maybe you can fix that?

davidhellmann commented 1 year ago

🤔

engram-design commented 1 year ago

Should be fixed in this PR https://github.com/verbb/super-table/pull/528