Improve multi-value and checkbox support for BPMN based modellers

Created on 9 February 2023, almost 2 years ago
Updated 12 June 2024, 6 months ago

Problem/Motivation

When at least one action exists that is using a '#type' => 'checkboxes' field within its configuration form, then the following error message appears on the modeller UI:

<em class="placeholder">Warning</em>: Array to string conversion in <em class="placeholder">Drupal\eca_modeller_bpmn\ModellerBpmnBase-&gt;prepareConfigFields()</em> (line <em class="placeholder">766</em> of <em class="placeholder">modules/contrib/eca/modules/modeller_bpmn/src/ModellerBpmnBase.php</em>). <pre class="backtrace">Drupal\eca_modeller_bpmn\ModellerBpmnBase-&gt;prepareConfigFields(Array) (Line: 591)
Drupal\eca_modeller_bpmn\ModellerBpmnBase-&gt;properties(Object, &#039;action&#039;, &#039;bpmn:Task&#039;, Array) (Line: 547)
Drupal\eca_modeller_bpmn\ModellerBpmnBase-&gt;getTemplates() (Line: 76)
Drupal\bpmn_io\Plugin\ECA\Modeller\BpmnIo-&gt;edit() (Line: 61)
Drupal\bpmn_io\Controller\BpmnIo-&gt;add()
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber-&gt;Drupal\Core\EventSubscriber\{closure}() (Line: 580)
Drupal\Core\Render\Renderer-&gt;executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber-&gt;wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber-&gt;Drupal\Core\EventSubscriber\{closure}() (Line: 163)
Symfony\Component\HttpKernel\HttpKernel-&gt;handleRaw(Object, 1) (Line: 74)
Symfony\Component\HttpKernel\HttpKernel-&gt;handle(Object, 1, 1) (Line: 58)
Drupal\Core\StackMiddleware\Session-&gt;handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle-&gt;handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache-&gt;pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache-&gt;handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware-&gt;handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware-&gt;handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\StackedHttpKernel-&gt;handle(Object, 1, 1) (Line: 681)
Drupal\Core\DrupalKernel-&gt;handle(Object) (Line: 19)

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Feature request
Status

Active

Version

2.1

Component

Code

Created by

🇩🇪Germany mxh Offenburg

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

Comments & Activities

  • Issue created by @mxh
  • 🇩🇪Germany jurgenhaas Gottmadingen

    Moving this to ECA as the config field preparation is being done in the base BPMN modeller that belongs to ECA.

    @mxh the stacktrace looks like is not a version that I can reproduce this with. The given line numbers are within comments and that doesn't seem to be right. Maybe you could post the stacktrace without markup?

    Also, could you provide more details about version of used components, please? Because I can't reproduce the problem. Checkboxes should be supported and I see plugins that use it, but I still don't get the error message.

  • 🇩🇪Germany mxh Offenburg

    Here is the stack trace from the logs:

    Warning: Array to string conversion in Drupal\eca_modeller_bpmn\ModellerBpmnBase->prepareConfigFields() (line 766 of [...]/web/modules/contrib/eca/modules/modeller_bpmn/src/ModellerBpmnBase.php)
    #0 [...]/web/core/includes/bootstrap.inc(158): _drupal_error_handler_real(2, 'Array to string...', '/Users/mxh/proj...', 766)
    #1 [...]/web/modules/contrib/eca/modules/modeller_bpmn/src/ModellerBpmnBase.php(766): _drupal_error_handler(2, 'Array to string...', '/Users/mxh/proj...', 766)
    #2 [...]/web/modules/contrib/eca/modules/modeller_bpmn/src/ModellerBpmnBase.php(591): Drupal\eca_modeller_bpmn\ModellerBpmnBase->prepareConfigFields(Array)
    #3 [...]/web/modules/contrib/eca/modules/modeller_bpmn/src/ModellerBpmnBase.php(547): Drupal\eca_modeller_bpmn\ModellerBpmnBase->properties(Object(Drupal\oc_eca\Plugin\Action\TokenGetFieldNames), 'action', 'bpmn:Task', Array)
    #4 [...]/web/modules/contrib/bpmn_io/src/Plugin/ECA/Modeller/BpmnIo.php(76): Drupal\eca_modeller_bpmn\ModellerBpmnBase->getTemplates()
    #5 [...]/web/modules/contrib/bpmn_io/src/Controller/BpmnIo.php(61): Drupal\bpmn_io\Plugin\ECA\Modeller\BpmnIo->edit()
    #6 [internal function]: Drupal\bpmn_io\Controller\BpmnIo->add()
    #7 [...]/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array(Array, Array)
    #8 [...]/web/core/lib/Drupal/Core/Render/Renderer.php(580): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
    #9 [...]/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure))
    #10 [...]/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array)
    #11 [...]/vendor/symfony/http-kernel/HttpKernel.php(163): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
    #12 [...]/vendor/symfony/http-kernel/HttpKernel.php(74): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1)
    #13 [...]/web/core/lib/Drupal/Core/StackMiddleware/Session.php(58): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #14 [...]/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #15 [...]/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #16 [...]/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #17 [...]/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #18 [...]/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #19 [...]/web/core/lib/Drupal/Core/StackMiddleware/StackedHttpKernel.php(51): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #20 [...]/web/core/lib/Drupal/Core/DrupalKernel.php(681): Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #21 [...]/web/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request))
    #22 {main}
    .
  • 🇩🇪Germany mxh Offenburg

    I'm using ECA 1.1.1 and BPMN io 1.1.1. The affected action is a custom implementation, which is using a checkboxes field element. Without a checkboxes element the error is gone.

  • 🇩🇪Germany jurgenhaas Gottmadingen

    We do currently support checkboxes similarly to radios and select fields:

              case 'checkboxes':
              case 'radios':
              case 'select':
                $fields[] = $this->optionsField($key, $label, $weight, $description, $definition['#options'], (string) $value, $definition['#required'] ?? FALSE);
                continue 2;
    

    The first 2 have not yet been implemented by ECA modules, only the select field type. But the way it's being implemented is that we expect a string value, which works just fine for select fields, as long as they don't allow multiple values to be selected. In that case, the value would be an array as it is with checkboxes. Radios though provide multiple options but only a single value, that should be fine.

    So, where this falls short is for checkboxes and select fields with multiple set to true. For the bpmn modellers we know so far, we would have to convert each option into a drop down list in these 2 cases.

  • 🇩🇪Germany jurgenhaas Gottmadingen

    As per #5 this needs to be implemented for select field with multi-value support and for checkboxes, that always accept multiple value.

    We need to investigate, if and how such widgets can be supported in bpmn_io and camunda modellers.

  • Assigned to jurgenhaas
  • 🇩🇪Germany jurgenhaas Gottmadingen

    I'm going to look into this, since bpmn_io has added support for more field types. Maybe there is something for this use case, and there is certainly support for checkboxes now, so that we can probably get rid of the yes|no dropdown as well.

  • Bringing my secondary issue from eca commerce over.

    @jurgenhaas Could you provide me with a bit more information?

    In my case, I'm using eca_commerce to trigger when an order is completed. My model then adds the user to the pre-configured paid member role and removes them from two lower level pre-configured roles. I'm assuming the roles options are the checkboxes causing the problem.

    What's the best workaround for this use case?

    You say "As a workaround, for now the eca commerce conditions should fall back to single value checkbox for now" (from my previous issue).

    Does this mean it will work if I split the 3 changes into separate modules, or do you mean it will only work with fields that have a single boolean checkbox option?

  • 🇩🇪Germany jurgenhaas Gottmadingen

    There is nothing you can do about this as a user. That one condition mentioned in 🐛 Undefined array key "parent_entity_type" CommerceDeriver.php:61 Fixed needs to be fixed with the mentioned workaround in that other issue.

  • Issue was unassigned.
  • 🇩🇪Germany jurgenhaas Gottmadingen
  • 🇩🇪Germany jurgenhaas Gottmadingen
Production build 0.71.5 2024