Sometimes required validation doesn't work with forms conditional logic

オープン
#9,172 コメント 8 件 リアクション 2 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
25/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
停滞
技術スタック
laravel, php
領域
backend

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

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

主要言語
PHP
スター
4.9k
フォーク
647
平均マージ
1日 45分
マージ済み PR(30日)
221

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

statamic/cms のほかの issue

statamic/cms の issue をすべて見る

似ている issue

PHP の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。