If you hit save on admin/config/workflow/eca on a fresh eca install without any models created yet you get two admin notices. One error message:

Warning: foreach() argument must be of type array|object, string given in Drupal\Core\Config\Entity\DraggableListBuilder->submitForm() (line 157 of core/lib/Drupal/Core/Config/Entity/DraggableListBuilder.php).
Drupal\Core\Config\Entity\DraggableListBuilder->submitForm(Array, Object) (Line: 108)
Drupal\eca\Entity\ListBuilder->submitForm(Array, Object)
call_user_func_array(Array, Array) (Line: 114)
Drupal\Core\Form\FormSubmitter->executeSubmitHandlers(Array, Object) (Line: 52)
Drupal\Core\Form\FormSubmitter->doSubmitForm(Array, Object) (Line: 592)
Drupal\Core\Form\FormBuilder->processForm('eca_collection', Array, Object) (Line: 320)
Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 219)
Drupal\Core\Form\FormBuilder->getForm(Object) (Line: 94)
Drupal\Core\Config\Entity\DraggableListBuilder->render() (Line: 23)
Drupal\Core\Entity\Controller\EntityListController->listing('eca')
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 564)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 158)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 80)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 58)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 708)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

and one success message underneath that the ordering has been saved. tested with drupal 9.3.5 and eca@dev and bpmn_io@beta

Issue fork drupal-3263859

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

rkoller created an issue. See original summary.

rkoller’s picture

but the more fundamental question that comes to mind in that context. why is a save button on that page necessary at all and what is its purpose? the page just provides a list view of all created and available models. there shouldnt be a need to save? function wise that list is no different to the list of for example content types.

jurgenhaas’s picture

Project: ECA: Event - Condition - Action » Drupal core
Version: 1.0.x-dev » 9.3.x-dev
Component: Code » entity system

This is a Drupal core issue in \Drupal\Core\Config\Entity\DraggableListBuilder::submitForm AFAICT.

The instruction $form_state->getValue($this->entitiesKey) return an array with all the entities in the list, but if that list is empty, this returns an empty string instead of an empty array.

cilefen’s picture

In order to get attention to this bug from entity system maintainers it should receive a new title.

larowlan’s picture

There's a second argument to that method, we should use an empty array as the default

jurgenhaas’s picture

Title: Error when model list is saved while no model is created yet » DraggableListBuilder::submitForm doesn't properly handle empty lists
Status: Active » Needs review

Changed the title of the issue as requested and provided an MR to add the default argument.

joachim’s picture

Status: Needs review » Needs work

The MR looks like it will fix the problem, but there's this point:

> but the more fundamental question that comes to mind in that context. why is a save button on that page necessary at all and what is its purpose? the page just provides a list view of all created and available models.

When the list is empty, why is the save button even shown?

jurgenhaas’s picture

Status: Needs work » Needs review

> When the list is empty, why is the save button even shown?

That's a fair question, and it should be hidden, when the list contains less than 2 items. I've added that to the MR.

danflanagan8’s picture

Here's a closely related issue: #2985414: DraggableListBuilder should hide actions if there are no entities

That one even has some tests. Seems like one or the other should be closed as a duplicate.

jurgenhaas’s picture

Status: Needs review » Closed (duplicate)

Thanks @danflanagan8 for the link. I'm closing this one here because the other one is more mature, especially because of the test.

danflanagan8’s picture

Issue tags: +Bug Smash Initiative

Great! Maybe we can get that other one over the finish line finally!