Field conditions don't work with Entry fields
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 35/100
- Tipo de issue
- Error
- Claridad
- Bastante claro
- Estado de actividad
- Estancado
- Stack tecnológico
- javascript, laravel, php
- Área
- frontend
Línea de trabajo
Start by reading Validator.js, especially prepareCondition and passesConditions, which the issue identifies as the points where the values are inspected. Use the reproduction steps with an Entry Field set to a maximum of one item, and check how its selected ID is compared with the condition value. The issue is resolved when the matching entry makes the dependent field show as expected.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Bug description
If I want to show or hide another field based on the value of an Entry Field the comparisons don't seem to work.
My hunch is that the comparison is between an integer and an integer as a string.
This could also be a result of using the Eloquent Driver, but I'm not sure.
These tests will fail.
expect(showFieldIf({ string_age: "== 13" })).toBe(true); // Fail
expect(showFieldIf({ age: "=== 13" })).toBe(false); // Pass
expect(showFieldIf({ string_age: "=== 13" })).toBe(true); // Pass ?
expect(showFieldIf({ string_age: "=== 13" })).toBe(true); // Fail
expect(showFieldIf({ string_age: "equals 13" })).toBe(true); // Fail
expect(showFieldIf({ string_age: "equals 13" })).toBe(false); // Pass
What I'm not clear on though is how the right hand value is interpreted.
I feel like the condition is maybe more like 123 === "123"
For example, if I console log from within the Validator.js in prepareCondition I can see that the left hand value is an integer, and the right hand value is a string.
lhs: [0: 25863]
rhs: "25863"
If I console log from passesConditions then I get something like:
field: "archive"
operator: "==="
value: "25863"
I've tried using in, contains, equal, and ===
I ended up writing my own condition and then using ParsIn on the Values coming in, I also added it to the Params but they were already ints.
The Left hand values also seem to be an array of IDs even when choosing a max of 1. So the comparisons could be completely off then.
How to reproduce
Using the Eloquent Driver might make a difference.
Create a fieldset using an Entry Field Max items 1
Create any other Field and then set the condition to show if the Entry Field is equal to t he ID from the entry.
In the editor, select the entry that matches the ID chosen in the condition.
The Field won't show.
Logs
Environment
Environment
Application Name: Tourism Calgary
Laravel Version: 11.45.1
PHP Version: 8.4.7
Composer Version: 2.8.9
Environment: adam
Debug Mode: ENABLED
URL: tourism-calgary.adam.paperleaf.dev
Maintenance Mode: OFF
Timezone: America/Edmonton
Locale: en
Cache
Config: NOT CACHED
Events: NOT CACHED
Routes: NOT CACHED
Views: CACHED
Drivers
Broadcasting: reverb
Cache: redis
Database: mysql
Logs: stack / single
Mail: log
Queue: database
Scout: algolia
Session: redis
Sentry
Enabled: YES
Environment: adam
Laravel SDK Version: 4.15.0
PHP SDK Version: 4.14.0
Release: NOT SET
Sample Rate Errors: 100%
Sample Rate Performance Monitoring: NOT SET
Sample Rate Profiling: NOT SET
Send Default PII: DISABLED
Statamic
Addons: 6
Sites: 1
Stache Watcher: Disabled (auto)
Static Caching: Disabled
Version: 5.57.0 PRO
Statamic Addons
aryehraber/statamic-captcha: 1.14.0
eminos/statamic-tabs: 1.2.0
statamic/collaboration: 1.0.1
statamic/eloquent-driver: 4.25.2
statamic/seo-pro: 6.7.0
thoughtco/statamic-restrict-fields: 1.1.0
Statamic Eloquent Driver
Asset Containers: eloquent
Assets: eloquent
Blueprints: eloquent
Collection Trees: eloquent
Collections: eloquent
Entries: eloquent
Forms: eloquent
Global Sets: eloquent
Global Variables: eloquent
Navigation Trees: eloquent
Navigations: eloquent
Revisions: eloquent
Sites: eloquent
Taxonomies: eloquent
Terms: eloquent
Tokens: eloquent
Installation
Fresh statamic/statamic site via CLI
Additional details
No response
- Lenguaje dominante
- PHP
- Estrellas
- 4.9k
- Forks
- 647
- Merge medio
- 1 d 8 h
- PR fusionados (30 d)
- 100
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
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de statamic/cms
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 82/100
Los mantenedores suelen responder en 1 día
-
assets
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
Los mantenedores suelen responder en 1 día
-
Make native filesystem directory permissions configurable to support shared POSIX ACL accessAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
Los mantenedores suelen responder en 1 día
-
accessibility
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
Los mantenedores suelen responder en 1 día
-
antlers
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
Los mantenedores suelen responder en 1 día
Todos los issues de statamic/cms
Issues similares
-
FrameworkBundle SecurityBundle
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
symfony/symfony-docs#23277 ·
Los mantenedores suelen responder en 3 días
-
[Sync EN] hard link does not need special permissionsPosiblemente ocupada @lacatoire la tomó hoy. Abiertosync-en
Dificultad 1/5 Menos de una hora Aptitud para principiantes 90/100
Los mantenedores suelen responder en 1 día
-
sync-en
Dificultad 1/5 Menos de una hora Aptitud para principiantes 76/100
Los mantenedores suelen responder en 4 días
-
bug mod:appointments
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
3pontos-tech/gil-benefits#303 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
Los mantenedores suelen responder en 1 día