-
-
Notifications
You must be signed in to change notification settings - Fork 73
New issue
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
Dropdown labels missing in email notifications when using dynamically overridden options via setFieldSettings #2300
Comments
Ah my bad for not specifying, this was for I thought for a second that maybe I still had some custom module logic that might be messing with this, but even after disabling anything custom, I consistently get the same results as the screenshot above. Is there anything in particular you can think of that may be causing this? I'm using a MariaDB instance, if that matters. |
Thanks for clarifying that, that does seem odd. Seems like it's not applying the snapshot data (the saved dynamic options) somehow. I'll continue looking into it to try and replicate things. |
So it feels a bit messy, but as a temporary workaround I've added this event hook to always use export labels for dropdowns that have snapshot data: Event::on(
Dropdown::class,
Dropdown::EVENT_MODIFY_VALUE_FOR_EXPORT,
function (ModifyFieldValueEvent $event) {
$fieldHandle = $event->field->handle;
$snapshotData = $event->submission->snapshot;
if (!empty($snapshotData['fields'][$fieldHandle]['options'])) {
$options = $snapshotData['fields'][$fieldHandle]['options'];
// Find label for the selected value
foreach ($options as $option) {
if (isset($option['value']) && $option['value'] == $event->value) {
$event->value = $option['label'];
}
}
}
}
); I was intending to do the same for |
Describe the bug
So I originally came across this issue trying to override Dropdown export values via
Dropdown::EVENT_MODIFY_VALUE_FOR_EXPORT
event to always export labels instead of Dropdown values. Checking the Dropdown field with$submission->getFieldValues()
, I noticed for Dropdown fields that had had their options dynamically overridden with setFieldSettings, labels would always benull
. E.g.Then out of curiosity, I checked to see if email notifications handled showing these dynamic labels properly, and alas it shows up as empty when displaying the label in the notification.
In the submission itself, these dynamic labels show up fine so it seems to be an issue with it not being exposed in notification/export contexts.
Steps to reproduce
sessionSelect
.Form settings
Craft CMS version
5.5.10
Plugin version
3.0.20
Multi-site?
No
Additional context
No response
The text was updated successfully, but these errors were encountered: