Sometimes required validation doesn't work with forms conditional logic

Offen
#9,172 8 Kommentare 2 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Anfängerfreundlichkeit
25/100
Issue-Typ
Bug
Klarheit
Klar beschrieben
Aktivitätsstatus
Veraltet
Tech-Stack
laravel, php
Bereich
backend

Rechercherichtung

Start by tracing how form-field conditional logic interacts with required validation, using the reproduction steps and clip in the issue. Confirm the behavior when the conditional field is hidden and the name is not “Rob.” Done means the hidden field no longer triggers a required validation error, while a visible required field is still validated.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

forms
Bug description

I've found that validating something as required sometimes doesn't always work. If it doesn't it triggers a required field validation even when the field isn't visible. Using required_if instead is a way to work around this.

I've ran into this on multiple occasions, but didn't jot them down and I can only replicate the issue in Forms today. I'll report the other scenarios as soon as I run into them again.

https://github.com/statamic/cms/assets/69107412/88f14902-a4db-404f-a7ac-7521c4cb46c9

In this clip the I'm conditional field shouldn't trigger a validation error when the name field isn't Rob.

How to reproduce
  1. Use conditional logic on a form field.
  2. Set that form field to required sometimes.
  3. Try to submit the form and get a required validation error even when the conditional field is hidden.
Logs

No response

Environment
Environment
Application Name: Statamic Peak Development
Laravel Version: 10.35.0
PHP Version: 8.2.10
Composer Version: 2.5.8
Environment: local
Debug Mode: ENABLED
URL: statamic-peak.test
Maintenance Mode: OFF

Cache
Config: NOT CACHED
Events: NOT CACHED
Routes: NOT CACHED
Views: CACHED

Drivers
Broadcasting: log
Cache: statamic
Database: mysql
Logs: stack / single
Mail: smtp
Queue: sync
Session: file

Statamic
Addons: 4
Antlers: runtime
Stache Watcher: Enabled
Static Caching: Disabled
Version: 4.39.0 PRO

Statamic Addons
studio1902/statamic-peak-browser-appearance: dev-main
studio1902/statamic-peak-commands: 3.1.0
studio1902/statamic-peak-seo: 7.3.2
studio1902/statamic-peak-tools: 4.0.3
Installation

Starter Kit using via CLI

Antlers Parser

None

Additional details

No response

Vorherrschende Sprache
PHP
Sterne
4.9k
Forks
647
Ø Merge
1 T. 45 Min.
Gemergte PRs (30 T.)
221

Entwicklungsumgebung

Dieses Projekt bietet weder Dev-Container noch Dockerfile noch Beitragsleitfaden – die Einrichtung liegt bei Ihnen. Beginnen Sie mit der README; die allgemeinen Schritte stehen in unserem Leitfaden für den ersten Beitrag.

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus statamic/cms

Alle Issues in statamic/cms

Ähnliche Issues

Weitere Issues zu PHP

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.