Skip to content

[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

@brionwolf

Description

@brionwolf

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

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions