- Issue created by @joelpittet
- Merge request !13Issue #3384140: Empty value using _none instead of empty string for Select2 integration → (Merged) created by joelpittet
- Open on Drupal.org →Core: 9.5.x + Environment: PHP 8.1 & MySQL 8
53:43 53:43 Queueing - last update
over 1 year ago 127 pass - Status changed to Needs review
over 1 year ago 11:45pm 29 August 2023 - last update
over 1 year ago 127 pass - 🇨🇦Canada joelpittet Vancouver
We found out that my MR/patch stored the
_none
value which was not intended though I would have thought the nice tests here would catch that, nevertheless I updated it to strip it out similar to:
core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/OptionsWidgetBase.php:110
But considering NameWidget doesn't extend from that (and doesn't need to) I just grabbed the part that was needed.
- First commit to issue fork.
-
heddn →
committed 7a74376b on 8.x-1.x authored by
joelpittet →
Issue #3384140 by joelpittet, heddn: Empty value using _none instead of...
-
heddn →
committed 7a74376b on 8.x-1.x authored by
joelpittet →
- 🇺🇸United States tkiehne
I'd hate to burst y'alls bubble here, but the filtering in the NameWidget uses array_search() which only returns the first key:
If needle is found in haystack more than once, the first matching key is returned. To return the keys for all matching values, use array_keys() with the optional filter_value parameter instead.
https://www.php.net/manual/en/function.array-search.php
So, if we have both title and generational in the form and the user leaves both blank, only one of these is going to get massaged to remove the "_none".
Should be something like this instead:
$indexes = array_keys($item, '_none', TRUE); foreach ($indexes as $index) { $item[$index] = ''; }
- 🇺🇸United States derekw
I confirm -- I am seeing the behavior described in #8 and a blank "Generational" field is being rendered as _none by the default name formatter.
- 🇺🇸United States tkiehne
I had to work up a patch to deploy a site tonight - here it is if it helps while waiting for a new release
- heddn Nicaragua
@tkiehne can you post a new issue with that in it and link it here? I'd like to get this fixed pretty quickly.
Automatically closed - issue fixed for 2 weeks with no activity.