cms icon indicating copy to clipboard operation
cms copied to clipboard

[5.x]: Link fields linking to deleted elements do not fail validation when required

Open mmikkel opened this issue 8 months ago • 1 comments

What happened?

Description

A required, empty Link field will not fail validation if it was linked to an element that has since been deleted.

https://github.com/user-attachments/assets/54eca80e-35c3-4283-8fdf-0d86c615873e

Steps to reproduce

  1. Create a Link field, add it to a field layout and make it required.
  2. Link to an entry in the Link field, and save the element.
  3. Delete the entry that was selected in the Link field.
  4. Navigate back to the element with the Link field in its layout. Confirm that the Link field now appears empty (since the entry it links to has been deleted).
  5. Save the element with the Link field. Confirm that the required, now empty Link field does not fail validation.

Expected behavior

An empty, required link field should always fail validation.

Actual behavior

Link fields linking to elements that has since been deleted, appears empty but passes validation when required.

Craft CMS version

5.7.10

PHP version

No response

Operating system and version

No response

Database type and version

No response

Image driver and version

No response

Installed plugins and versions

None

mmikkel avatar Jun 08 '25 20:06 mmikkel

Hi, thanks for reporting! I raised a PR for this.

i-just avatar Jun 10 '25 10:06 i-just

Craft 5.7.11 is out with that fix. Thanks again!

brandonkelly avatar Jun 24 '25 16:06 brandonkelly