Skip to content

The link fieldtype ignores the sometimes validator #13922

Description

@leon-fablr

Bug description

If you create a link field with a required validator, it will remove the "None" option and force you to choose a link - either a manually entered URL or select a entry from collections you specify.

If you give it the sometimes validator instead of the required validator (e.g. because you have the field hidden via display logic) it will still show the None option and allow you to select that and submit the form even if the field is visible.

Using both required and sometimes just makes the field always be required, even if hidden via display logic so isn't really possible here. I'm guessing the bug here is just that there's a check for the required validator that also needs to check for sometimes?

How to reproduce

  • Create a blueprint with a link field
  • Give the field the "sometimes" validator
  • Try and make a new entry using this blueprint with "None" selected.

Logs

Environment

Application Name: StatamicLaravel Version: 12.33.0PHP Version: 8.3.29Composer Version: 2.9.3Environment: local-dbDebug Mode: ENABLEDURL: localhostMaintenance Mode: OFFTimezone: UTCLocale: enCacheConfig: NOT CACHEDEvents: NOT CACHEDRoutes: NOT CACHEDViews: CACHEDDriversBroadcasting: logCache: databaseDatabase: mysqlLogs: stack / singleMail: logQueue: databaseSession: fileStoragepublic/storage: NOT LINKEDStatamicAddons: 7Sites: 1Stache Watcher: Disabled (auto)Static Caching: DisabledVersion: 5.66.0 PROStatamic Addonsanakadote/statamic-recaptcha: 2.0eminos/statamic-tabs: 1.2.0jezzdk/statamic-google-maps: 2.1.0patrickjunod/image-select: 1.0.0rias/statamic-redirect: 3.12.0statamic/eloquent-driver: 4.32.0withcandour/aardvark-seo: dev-masterStatamic Eloquent DriverAsset Containers: fileAssets: fileBlueprints: fileCollection Trees: fileCollections: fileEntries: eloquentFieldsets: fileForm Submissions: fileForms: fileGlobal Sets: fileGlobal Variables: fileNavigation Trees: fileNavigations: fileRevisions: fileSites: fileTaxonomies: fileTerms: eloquentTokens: file

Installation

Fresh statamic/statamic site via CLI

Additional details

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions