Problem/Motivation

Sometimes you only want to ensure that the same title doesn't exist in the same bundle.

So I'd vote to add a setting to only check for uniqueness within the same bundle. Disabled by default.

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

anybody created an issue. See original summary.

miroslavstankov made their first commit to this issue’s fork.

miroslavstankov’s picture

Assigned: Unassigned » miroslavstankov

I would like to work on this issue

miroslavstankov’s picture

Assigned: miroslavstankov » Unassigned
Status: Active » Needs review

This functionality—checking uniqueness only within the same bundle— as I can see is already implemented in the current codebase. I tested it with content types and taxonomy terms as follows:

- Tried adding the same title twice in the Article content type, and it correctly threw an error for duplicate titles.

- Then added the same title in a different content type (Basic page), and it allowed it, since uniqueness is scoped per bundle.

- Performed the same checks for taxonomy terms, with the expected behavior.

Additionally, I added a functional test to cover this scenario for extra assurance.

One more note: I replaced the deprecated @Constraint annotation with the newer PHP attribute syntax for validation constraints:

#[\Drupal\Core\Validation\Attribute\Constraint(
id: 'UniqueEntityTitle',
label: new TranslatableMarkup('Unique Entity Title', [], ['context' => 'Validation']),
type: ['string']
)]

Overall, no code changes are necessary to support the requested feature, as it’s already working as intended. Happy to discuss further if needed!

anybody’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: -Novice

Ne @miroslavstankov you're right, my bad! Nice new tests, RTBC from my side!

i-trokhanenko made their first commit to this issue’s fork.

i-trokhanenko’s picture

Status: Reviewed & tested by the community » Fixed

Committed, thanks!

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.