We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
When using a ternary statement within a partial to check if a value is set, the ternary expression is evaluated as true even if the value is null.
select_field
container.antlers.html
{{ select_field ? 'true' : 'false' }}
{{ partial:container :select_field="select_field" }}
This returns 'true' 🤯
When dumping select_field in the partial you'll see that this seems not correct:
{{ select_field | dump }}
Statamic\Fields\LabeledValue {#3116 ▼ // vendor/statamic/cms/src/Modifiers/CoreModifiers.php:613 #value: null #extra: array:1 [▶] }
No response
Environment Application Name: Statamic Laravel Version: 11.20.0 PHP Version: 8.3.9 Composer Version: 2.7.7 Environment: local Debug Mode: ENABLED URL: ternary.test Maintenance Mode: OFF Timezone: UTC Locale: en Cache Config: NOT CACHED Events: NOT CACHED Routes: NOT CACHED Views: CACHED Drivers Broadcasting: log Cache: file Database: sqlite Logs: stack / single Mail: log Queue: sync Session: file Statamic Addons: 0 Sites: 1 Stache Watcher: Enabled (auto) Static Caching: Disabled Version: 5.19.0 Solo
Fresh statamic/statamic site via CLI
The text was updated successfully, but these errors were encountered:
I wish there was a magic __toBool() method like __toString().
__toBool()
__toString()
Sorry, something went wrong.
We can probably make this work in Antlers though. 👌
This is already magically working with null values, but not when the ternary statement is used in a partial for some reason 🤷♂️
Successfully merging a pull request may close this issue.
Bug description
When using a ternary statement within a partial to check if a value is set, the ternary expression is evaluated as true even if the value is null.
How to reproduce
select_field
with some random options.select_field
container.antlers.html
with the following contentThis returns 'true' 🤯
When dumping
select_field
in the partial you'll see that this seems not correct:Logs
No response
Environment
Installation
Fresh statamic/statamic site via CLI
Additional details
No response
The text was updated successfully, but these errors were encountered: