Fieldsets with only images don't display

Created on 20 October 2023, 11 months ago
Updated 25 June 2024, 3 months ago

The logic in RowFieldset.php currently has $text = trim(strip_tags($child->content));. If the row only has an img tag then it strips that out as well and returns $show_fieldset = FALSE; and then rows with just an image don't show. If we switch that to $text = trim(strip_tags($child->content, '<img>')); to allow images, then rows with just an image will still show up.

πŸ› Bug report
Status

Needs work

Version

4.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States tjhellmann Indianapolis, IN

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @tjhellmann
  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Seems like something that could be a configuration in the form

  • Status changed to RTBC 11 months ago
  • πŸ‡ΊπŸ‡ΈUnited States chucksimply

    Yup, after the upgrade to 4.0, all image-only fieldsets don't show. Patch works great. Lets push!

  • πŸ‡¬πŸ‡§United Kingdom alx_benjamin

    I have a slightly different issue.
    $child->content is not a string, in my case, but a Drupal\Core\Render\Markup.
    Any advice? :(

    Thank you

  • Status changed to Needs work 11 months ago
  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Think this should be a configuration form so you can choose tags, that may solve it.

  • πŸ‡¬πŸ‡§United Kingdom alx_benjamin

    Sorry @smustgrave,

    I've updated my comment, It is a different issue.
    Please see above.

    Thank you.

  • πŸ‡¬πŸ‡§United Kingdom alx_benjamin

    Here is a snapshot.

  • πŸ‡¬πŸ‡§United Kingdom alx_benjamin

    Found the culprit,

    the ['#markup' => "html goes here'] had to be wrapped in render() function.

  • Status changed to RTBC 10 months ago
  • πŸ‡­πŸ‡ΊHungary szato

    I'm using module v 4.0.0 with Drupal 10.1.6. Have a fieldset (div wrapper) with only image field - image not rendered.
    Patch solved the issue.

    I'm moving to RTBC.

  • Status changed to Needs work 10 months ago
  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Since there could be other tags, thing this should be a configuration form to allow others tags if needed.

  • πŸ‡ΊπŸ‡ΈUnited States chucksimply

    I'm using the module Views Entity Form Fields β†’ to display form fields in a view. Any form fields in a fieldset (on their own) don't display (same behavior as img).

    @smustgrave is right, there needs to be support for more tags.

  • πŸ‡­πŸ‡ΊHungary szato

    This bug is connected to: #3369756 Empty fields are not hidden ✨ Empty fields are not hidden Fixed

    @smustgrave
    I don't think adding a configuration is the right way. It's about checking whether the rendered output of the fieldset is empty or not. We should fix/refactor code changes committed in #3369756

  • πŸ‡ΊπŸ‡ΈUnited States bcobin

    Holy cow - I spent the day trying to figure out why my images weren't displaying; I'm rebuilding from a dev site and in creating the identical view, one view displayed images while the other didn't. I was going nuts. Then I found this post. Patch fixed it and, sure enough, I see that the dev site was running 8.34.

    I think this should be more heavily flagged, though, if possible - those doing upgrades on live sites could easily have all their images disappear without having a clue as to what did it. Just sayin'.

    Thanks for the module... and for the fix... Whew!

  • πŸ‡ΊπŸ‡¦Ukraine vlad.dancer Kyiv

    Another quick workaround add hidden span tag <span class="hidden">&nbsp;</span>.

  • πŸ‡³πŸ‡±Netherlands interactivex

    The patch didn't work for version 4.0.1 so I created a patch for that version. I can confirm now the images do work again.

Production build 0.71.5 2024