Field conditions don't work with Entry fields
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 35/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
- 技术栈
- javascript, laravel, php
- 领域
- frontend
调研方向
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.
由索引模型根据 Issue 内容生成。
描述
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
- 主要语言
- PHP
- 星标
- 4.9k
- 派生
- 647
- 平均合并
- 1 天 20 小时
- 30 天内合并 PR
- 113
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
statamic/cms 的其他 Issue
-
preferences
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 74/100
维护者通常 1 天内回复
-
accessibility
难度 2/5 1-3 小时 新手友好度 74/100
维护者通常 1 天内回复
-
[7.x] Reintroduce parser error for mixed pipe/shorthand modifier syntax可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭antlers
难度 2/5 1-3 小时 新手友好度 66/100
维护者通常 1 天内回复
-
navigations
难度 3/5 1-2 天 新手友好度 68/100
维护者通常 1 天内回复
相似的 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 66/100
维护者通常 1 天内回复
-
sync-en
难度 2/5 1-3 小时 新手友好度 62/100
维护者通常 1 天内回复
-
sync-en
难度 2/5 1-3 小时 新手友好度 66/100
维护者通常 4 天内回复
-
Перевод устарел
难度 2/5 1-3 小时 新手友好度 66/100
-
Adapter: Algolia Performance
难度 2/5 1-3 小时 新手友好度 62/100