Undefined array key product_quantity_fieldset

Created on 14 May 2025, 23 days ago

Problem/Motivation

Upon creating a new Product Type Quantity Limit I get error:

Warning: Undefined array key "product_quantity_fieldset" in Drupal\commerce_product_quantity\Form\ProducttypeForm->submitForm() (line 234 of modules/contrib/commerce_product_quantity/src/Form/ProducttypeForm.php).

Drupal\commerce_product_quantity\Form\ProducttypeForm->submitForm()
call_user_func_array() (Line: 105)
Drupal\Core\Form\FormSubmitter->executeSubmitHandlers() (Line: 43)
Drupal\Core\Form\FormSubmitter->doSubmitForm() (Line: 589)
Drupal\Core\Form\FormBuilder->processForm() (Line: 321)
Drupal\Core\Form\FormBuilder->buildForm() (Line: 73)
Drupal\Core\Controller\FormController->getContentResult()
call_user_func_array() (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 593)
Drupal\Core\Render\Renderer->executeInRenderContext() (Line: 121)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext() (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 183)
Symfony\Component\HttpKernel\HttpKernel->handleRaw() (Line: 76)
Symfony\Component\HttpKernel\HttpKernel->handle() (Line: 53)
Drupal\Core\StackMiddleware\Session->handle() (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle() (Line: 28)
Drupal\Core\StackMiddleware\ContentLength->handle() (Line: 32)
Drupal\big_pipe\StackMiddleware\ContentLength->handle() (Line: 116)
Drupal\page_cache\StackMiddleware\PageCache->pass() (Line: 90)
Drupal\page_cache\StackMiddleware\PageCache->handle() (Line: 50)
Drupal\ban\BanMiddleware->handle() (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle() (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle() (Line: 36)
Drupal\Core\StackMiddleware\AjaxPageState->handle() (Line: 38)
Drupal\mercury_editor\StackMiddleware\AjaxPageState->handle() (Line: 51)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle() (Line: 709)
Drupal\Core\DrupalKernel->handle() (Line: 19)


Steps to reproduce

  • Install module.
  • Go to: /admin/config/system/commerce_product_type_quantity.
  • Add a product type.

Proposed resolution

I've noticed the first time that line is run product_quantity_fieldset is set, but the second time $value only has the key "add_name".

So looks like all that is needed is a ?? NULL after $product_quantity = $value['product_quantity_fieldset']

🐛 Bug report
Status

Active

Version

2.0

Component

Code

Created by

🇬🇧United Kingdom dahousecat

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

Comments & Activities

  • Issue created by @dahousecat
  • 🇬🇧United Kingdom dahousecat

    I added that fix but then got error:

    Warning: Undefined array key 0 in Drupal\commerce_product_quantity\Form\ProducttypeForm->validateForm() (line 207 of modules/contrib/commerce_product_quantity/src/Form/ProducttypeForm.php).

    So added a fix for that too and can now add product types without any warnings.

Production build 0.71.5 2024