cms
cms copied to clipboard
[5.x]: Link fields linking to deleted elements do not fail validation when required
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
- Create a Link field, add it to a field layout and make it required.
- Link to an entry in the Link field, and save the element.
- Delete the entry that was selected in the Link field.
- 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).
- 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
Hi, thanks for reporting! I raised a PR for this.
Craft 5.7.11 is out with that fix. Thanks again!