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

Link Fieldtype does not enforce required on "First Child" option, if there is no first child #10834

Closed
fighter3005 opened this issue Sep 25, 2024 · 1 comment

Comments

@fighter3005
Copy link

Bug description

If I set the Link to UR, leave the field empty and try to save the collection, it triggers the required validation.
If I set the Link to First Child and save the collection, the collection is saved successfully and the link is null.
I assume this is not expected, since null is an "empty" value and required means not empty as per your documentation?

image

image

Bildschirmfoto 2024-09-25 um 11 05 09

How to reproduce

Use the Link Fieldtype in some Fieldset.
set the Link as required.
Put the link in the last collection at the end, so First Child is null.
save the collection and be surprised, it does not trigger the required validation.

Logs

No response

Environment

"php": "^8",
    "eminos/statamic-tabs": "v1.2.0",
    "fuf/asset-glide-url": "*",
    "fuf/n8n-viewer": "*",
    "laravel/framework": "v11.23.5",
    "laravel/tinker": "v2.9.0",
    "statamic/cms": "v5.25.0",
    "thoughtco/statamic-restrict-fields": "v1.1.0"

Installation

Fresh statamic/statamic site via CLI

Additional details

No response

@jasonvarga
Copy link
Member

jasonvarga commented Sep 25, 2024

This is more or less expected behavior.

Think about it from the other angle:

  • Your page has a child.
  • You set the link to first child.
  • You go to the page tree and drag the child away, so now the page doesn't have a child. Should that be prevented here too because your entry wants a first child?

We don't validate that a first child is available. If there is one, it'll reference it. Otherwise, it won't.

If this is important to you, you can create a custom validation rule and apply it to that field.
https://statamic.dev/validation#custom-rules

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants