Hi,
I have a custom module that provides regions to Entity View Displays in conjunction with layout module. I am extending the EntityViewDisplayEditForm class with mine where I add some logic for this. It's like Display Suite does it but more on point/single-purpose.

Anyway, what I have encountered in the past(beta days of D8) was that the tablePreRender method always ended up in infinite loop so I had to override it in my class. The fix was simple(the same as in the patch). But now with some changes to the FieldUiTable the method for rendering the table(FieldUiTable::tablePreRender) is also called from the form method since the EntityViewDisplayEditForm uses '#type' => 'field_ui_table' now. This would mean I would have to override the FieldUiTable element in order to prevent overriding two methods for the same reason.

I had a look at the issue again and the source of my infinite loop is the way the core is processing the rows in the table and how it handles the parents.

The code is:

$regions = $elements['#regions'];
    $tree = ['' => ['name' => '', 'children' => []]];
    $trees = array_fill_keys(array_keys($regions), $tree);

    $parents = [];
    $children = Element::children($elements);
    $list = array_combine($children, $children);

    // Iterate on rows until we can build a known tree path for all of them.
    while ($list) {
      foreach ($list as $name) {
        $row = &$elements[$name];
        $parent = $row['parent_wrapper']['parent']['#value'];
        // Proceed if parent is known.
        if (empty($parent) || isset($parents[$parent])) {
          // Grab parent, and remove the row from the next iteration.
          $parents[$name] = $parent ? array_merge($parents[$parent], [$parent]) : [];
          unset($list[$name]);
...

and the "bug", in my opinion, is the if (empty($parent) || isset($parents[$parent])) {.

What that does basically is it will process the row/field only if the parent is empty(ie. no "region" is assigned = hidden field) or if the parent/region was already processed. What will happen is that the parent/region will never be processed if it has value since the first condition makes sure this won't happen. So the loop will never fill up the $parents variable and in my case it will cause infinite loop because my empty region is called 'hidden'.

If I remove that condition completely my form renders just fine and if I disable my module, so the base form is used, it renders fine as well.

So I think in order to make mine, and maybe DS maintainers(or any other contrib module that will fiddle with these forms), life easier I suggest this condition be removed.

Members fund testing for the Drupal project. Drupal Association Learn more

Comments

ivanjaros created an issue. See original summary.

swentel’s picture

Will have to test with fieldgroup too since that module deals with a lot parenting.

amateescu’s picture

Component: field system » field_ui.module

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

slydevil’s picture

I noticed that this only happened when I tried to add a Details group within a Fieldset group. I did not know at the time that the Details groups was a collapsible fieldset. I had to apply a portion of this patch to delete the Details group.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.