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

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

Closed
davidhellmann opened this issue May 11, 2023 · 11 comments
Closed

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

davidhellmann opened this issue May 11, 2023 · 11 comments

Comments

@davidhellmann
Copy link

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
Copy link
Author

Not sure if there is a relation to this issue: craftcms/cms#13155

@davidhellmann
Copy link
Author

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

@davidhellmann
Copy link
Author

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

@davidhellmann
Copy link
Author

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

@brandonkelly
Copy link
Contributor

@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
Copy link
Author

@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
Copy link
Contributor

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

@davidhellmann
Copy link
Author

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

@davidhellmann
Copy link
Author

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
Copy link
Author

🤔

@engram-design
Copy link
Member

Should be fixed in this PR #528

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

No branches or pull requests

4 participants