- Issue created by @jorisclaes
- π³πΏNew Zealand quietone
Changes are made on on 11.x (our main development branch) first, and are then back ported as needed according to the Core change policies β .
Changing tags per Issue tags field β and Issue tags -- special tags β - Merge request !11185Issue #3477324 by andypost, alexpott: Fix usage of str_getcsv() and fgetcsv() for PHP 8.4 β (Closed) created by anish.ir
Hey,
I have implemented the fix to ensure the Boolean field formatter properly displays FALSE when the value is empty. Previously, empty boolean fields were not rendered, which caused confusion for end users expecting a clear β or β (or any other format) output.
Changes Made:
- Updated BooleanFormatter.php to handle NULL values by defaulting them to FALSE.
- Ensured that empty boolean fields are now correctly displayed in Views or any other place too, where the field is is used.
- Refactored the logic to prevent skipped fields and improve code readability.
Commit: Link
Please review and test the patch to confirm expected behavior.
Let me know if any improvements are needed.Thanks!
We need the code changes in the form of a merge request to be reviewed. Thank you.
- π§πͺBelgium jorisclaes
My merge request was closed.
@anish.ir
What is wrong with returning before the foreach ?
The foreach is skipped when the field is empty, so the variable elements will always be empty.if ($items->isEmpty()) { return [['#markup' => $formats[$format][1]]]; }
This I get and is and is an good improvement:
$value = !empty($item->value) ? (bool) $item->value : FALSE;
Hey @jorisclaes,
Thanks for the clarification!
I initially removed the $items->isEmpty() check because I added a fallback at the end:
return !empty($elements) ? $elements : [['#markup' => $formats[$format][1]]];
However, I now see that keeping the early return makes the logic clearer and more efficient, since it avoids even entering the loop when there are no field values.
I'll restore the$items->isEmpty()
check and update the MR. Thanks for the feedback!Also, while raising the MR against 11.x, it reflected around 1236 commits to be merged to the 11.x branch, so I think the 3505775-boolean-formatter-behavior branch needs a rebase to sync with the latest 11.x.
Please let me know, what's best here, to proceed further.
Thanks!- πΊπΈUnited States smustgrave
have not reviewed but #6 is correct.
Also if not already included but test coverage will be required.
- Merge request !11209Resolve #3505775 "Boolean formatter behavior" β (Open) created by Unnamed author
Hey,
The MR with the required changes have been raised. Please have a look.
Thanks !- π§πͺBelgium jorisclaes
@13
I don't have much experience with writing test for Drupal, if I forgot something plz let me know.
- πΊπΈUnited States smustgrave
Thanks, left some small comments on the MR
If you are another contributor eager to jump in, please allow the previous poster at least 48 hours to respond to feedback first, so they have the opportunity to finish what they started!
- π§πͺBelgium jorisclaes
Thanks for the feedback @smustgrave,
I reverted out of scope changesAnd added a comment that it is a fallback with FALSE as default value.