Sometimes required validation doesn't work with forms conditional logic

Abierto
#9,172 8 comentarios 2 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
25/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Estancado
Stack tecnológico
laravel, php
Área
backend

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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

Lenguaje dominante
PHP
Estrellas
4.9k
Forks
647
Merge medio
1 d 45 min
PR fusionados (30 d)
221

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de statamic/cms

Todos los issues de statamic/cms

Issues similares

Más issues de PHP

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.