Support from Acquia helps fund testing for Drupal Acquia logo

Comments

geerlingguy created an issue. See original summary.

geerlingguy’s picture

FileSize
136.71 KB

If I inspect the source after IEF loads its form inline, I see there's an empty <legend></legend> for the new fieldset it adds in:

Empty legend for IEF fieldset

filsterjisah’s picture

Same issue here. Only applies when the IEF field is required.

After having a closer in the InlineEntityFormComplex class:

This is where the add form gets rendered (shown by default if the field is required) (1):

else {
      // There's a form open, show it.
      if ($form_state->get(['inline_entity_form', $this->getIefId(), 'form']) == 'add') {
        $element['form'] = [
          '#type' => 'fieldset',
          '#attributes' => ['class' => ['ief-form', 'ief-form-bottom']],
          'inline_entity_form' => $this->getInlineEntityForm(
            'add',
            $this->determineBundle($form_state),
            $parent_langcode,
            NULL,
            array_merge($parents, ['inline_entity_form'])
          )
        ];

The wrapper fieldset loses its label when this field has no existing entities yet (2):

// No entities have been added. Remove the outer fieldset to reduce
// visual noise caused by having two titles.
if (empty($entities)) {
  $element['#type'] = 'container';
}

What if we change the element type from fieldset to container for (1) and remove the no-entities-added case (2)? This would remove the visible fieldset around the inline entity add form, but would maintain the IEF its label all the time.

filsterjisah’s picture

filsterjisah’s picture

Status: Active » Needs review
Alex Bukach’s picture

#4 works fine for me. Thanks!

jeffschuler’s picture

Status: Needs review » Reviewed & tested by the community

Yes... when I changed my IEF to Required, the field label disappeared.

Patch in #4 is working for me, too.

Oddly, duplicate titles are shown when the "Simple" version of the form field is displayed. I'm curious why this code is in the the InlineEntityFormComplex.php instead of InlineEntityFormSimple.php.

andrey.troeglazov’s picture

FileSize
41.2 KB
43.32 KB

Hello,
The #4 patch applied correctly and working as expected.
+1 for RTBC.
Tested on dev branch.
Simple form works ok for me.

andrey.troeglazov’s picture

Issue tags: +IEF Release 8.x-1.0
jonathanshaw’s picture

I wonder if removing the fieldset has negative accessibility implications. Still, losing the label is even worse ...

ShermanIO’s picture

The Patch 4# works perfectly for me!

HumbertoJZG’s picture

The patch #4 doesn't work for me.

HumbertoJZG’s picture

Priority: Normal » Major
HumbertoJZG’s picture

The patch #4 doesn't work for me because i have multiple values in the field IEF.

When i tried add something from the list, the name disapear from the legend of the fieldset.

joachim’s picture

Status: Reviewed & tested by the community » Needs review

Setting to needs work based on #14.

HumbertoJZG’s picture

I found the solution that i looking for, but i don't know how to up the changes.

jonathanshaw’s picture

@HumbertoJZG it would really help if you could explain precise steps to reproduce the problem, and say what solution you found.

HumbertoJZG’s picture

FileSize
18.77 KB
48.47 KB
52.82 KB

I have multiple values in the inline_entity_form_complex field, when i pick one, i see the form. But the field/name for the legend desapear.

Then check if there was an open form, and pass the title of the type of referenced content I want to show.

After to applying my changes, i can see the field/name for the legend. work for me.

joachim’s picture

Status: Needs review » Needs work

I meant to set this to NW in my last comment...

geek-merlin’s picture

Thanks a lot for debugging this!

To me it looks like #3/#4 spots the code to look into, but adds the wrong solution. This must be fixed without changing existing markup (except for the buggy ;-). Let's find the right condition for the "Remove the outer fieldset" part, maybe involving $open_form.

andyg5000’s picture

In my case, the code below changes the wrapper element from a "details" to a "container". This causes the parent field (invoking IEF) to lose it's title and description (see keep/removed screenshots). In my instance I want to keep all this stuff, but maybe things like commerce want it removed.

Line 577:

      // No entities have been added. Remove the outer fieldset to reduce
      // visual noise caused by having two titles.
      if (empty($entities)) {
        $element['#type'] = 'container';
      }
sinn’s picture

FileSize
170.34 KB

#4 works for me even for multiple values field. From comments #14, #16, #18 I have not understood what is wrong and alternative solution wasn't provided.

Form after applying patch #4.

sinn’s picture

Issue is in the code:

// No entities have been added. Remove the outer fieldset to reduce
      // visual noise caused by having two titles.
      if (empty($entities)) {
        $element['#type'] = 'container';
      }

From the history I see that this code is from D7 version. There isn't fieldset wrapper in D8 version. $element['#type'] == 'details' now. There is a difference how collapsible elements work in D7 and D8 - https://www.drupal.org/node/1852020. I have not found "visual noise caused by having two titles" after removing this code.

After applying patch #23 additional border is shown in comparing with solution #4 but might be this solution is more consistent based on the implementation of the form in another cases and #20.

#23

jonathanshaw’s picture

This seems like the right approach to me.

joevagyok’s picture

Status: Needs review » Needs work

Good job with #23, looks good and it works.
However, this should be tested. @sinn, please extend the ComplexWidgetTest to check for the presence of this element and the title.

sinn’s picture

Test that shows the issue is attached.

Status: Needs review » Needs work
jonathanshaw’s picture

Status: Needs review » Reviewed & tested by the community

Looks good to me, thanks @sinn!

Andras_Szilagyi’s picture

Tested, works for me

joevagyok’s picture

Reviewed and tested, thanks @sinn!

Ollie222’s picture

That looks to solve the problem for me too, thanks @sinn

joachim’s picture

> To me it looks like #3/#4 spots the code to look into, but adds the wrong solution. This must be fixed without changing existing markup (except for the buggy ;-). Let's find the right condition for the "Remove the outer fieldset" part, maybe involving $open_form.

I think what @geek-merlin means here is that it feels a bit iffy to just remove this chunk of code without understanding what it was trying to do.

> // No entities have been added. Remove the outer fieldset to reduce
> // visual noise caused by having two titles.

When would two titles be shown?

The patch works for me on the complex widget, but I'm wary of committing it in case it breaks something we've not considered.

jonathanshaw’s picture

#23 attempts to answer these questions and explain the history. Can you say in what way it is insufficient.?

joachim’s picture

> Can you say in what way it is insufficient?

In the 'co-maintainer was multi-tasking while using this module on a work project and didn't read all of the comments' way ;)

I'll commit this when I have a moment.

Thank you for the explanation.

  • joachim committed 967f1d7 on 8.x-1.x authored by sinn
    Issue #2842744 by sinn, filsterjisah, HumbertoJZG, geerlingguy, andrey....
joachim’s picture

Status: Reviewed & tested by the community » Fixed

Committed.

Thanks to everyone who's worked on this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.