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

[5.x]: Validation Error thrown "slug cannot be blank" on inline matrix fields with a single required entry type were the title is hidden, the slug is in the URI #14947

Closed
brionwolf opened this issue May 6, 2024 · 2 comments
Assignees
Labels

Comments

@brionwolf
Copy link

What happened?

Description

I realize this is a very niche issue, but sharing: craft throws a validation error stating "slug cannot be blank" on matrix fields where Site settings include the entry's slug in the URL Format, the "Min Entries" is set to greater than one, the "View mode" is As inline-editable blocks, and the title/slug are hidden fields on the Associated Entry Type.

Steps to reproduce

  1. Create an entry type with various fields
  2. Set the Title and slug to hidden, and include logic for creating a title (Doesn't matter if the logic is just a common string, or dynamic based on custom fields).
  3. Associate the entry type with a matrix field as the only entry type
  4. Set an Entry URI format that includes the entry's slug.
  5. Set the Min entries option to a number greater than zero
  6. Set the View mode to "As inline-editable Blocks"
  7. Assign the matrix field to a section that can be edited and attempt to create an entry

Expected behavior

  • Craft creates the Min-Entries set of entries for the matrix field automatically without errors.

Actual behavior

  • Craft creates a single block (even if the "Min Entries" is set to more than one), throws an error "Could not save entry" (with 404 errors in Yii console) when attempting to autosave, and throws a validation error "Slug cannot be blank" when manually saving.

Screencaptures:

animated screen capture or the craft CMS control panels depicting the above issue

Notes/workarounds

  • Issue doesn't occur if I do not hide the title field (Slug field can remain hidden).
  • Issue doesn't occur if I set the matrix field view to "As cards" or "As an element index" (where I need to create a new entry for the field either from a slide-out drawer or new tab).
  • Issue doesn't occur if I use another unique identifier in the URI format (ie: the entry id).
  • Issue doesn't occur if I set the "Min Entries" field to 0, while still setting the field to "required" on associated field layouts.

Craft CMS version

Craft Pro 5.1.0

PHP version

8.3.4

Operating system and version

MacOS Sonoma 14.4.1 (23E224)

Database type and version

MySQL 8.3.0

Image driver and version

GD 8.3.4

Installed plugins and versions

  • CKEditor | 4.0.4
@i-just
Copy link
Contributor

i-just commented May 7, 2024

Hi, thanks for reporting! I can replicate this with a matrix in matrix setup where both matrix fields are in “as inline-editable blocks” mode, and the nested matrix has the title and slug fields hidden. I raised a PR for this.

@brandonkelly
Copy link
Member

Craft 5.1.2 is out with a fix for this. Thanks again!

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

3 participants