Exception: The position 0, 0 is not empty.

Created on 29 April 2022, over 2 years ago
Updated 2 February 2024, 10 months ago

Problem/Motivation

I'm working on a contrib module to extend business rules with commerce ( Commerce Business Rules ).

When adding the commerce conditions element to the business rules condition mix whenever you enable a rule on the commerce element it triggers with ajax a $form_state->setRebuild(); thus resulting in the following exception:
Exception: The position 0, 0 is not empty. in Drupal\business_rules\Util\Flowchart\Matrix->putElementInPosition() (line 302 of /var/www/html/web/modules/contrib/business_rules/src/Util/Flowchart/Matrix.php).

Steps to reproduce

Add a custom button to the condition form to trigger $form_state->setRebuild();

/**
 * Implements hook_form_FORM_ID_alter().
 */
function hook_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) {
  if ($form_id === 'business_rules_condition_edit_form') {
          $form['actions']['rebuild'] = [
            '#type'   => 'submit',
            '#value'  => t('Rebuild'),
            '#submit' => ['_custom_form_submit'],
            '#op'     => 'rebuild',
            '#weight' => 7,
          ];
    }
  }
}
function _custom_form_submit(array $form, \Drupal\Core\Form\FormStateInterface $form_state){
  $form_state->setRebuild();
}
🐛 Bug report
Status

Fixed

Version

2.0

Component

Code

Created by

🇬🇧United Kingdom lexsoft London

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024