An "ArgumentCountError" occurs when adding a Button Box "Buttons" field to an existing entry
"ArgumentCountError: Too few arguments to function craft\fields\BaseOptionsField::normalizeValue(), 1 passed in /craft/vendor/verbb/buttonbox/src/fields/Buttons.php on line 153 and exactly 2 expected in /craft/vendor/craftcms/cms/src/fields/BaseOptionsField.php:273"
Buttons.php
BaseOptionsField.php
I believe the fix is to change this (on line 153 of /craft/vendor/verbb/buttonbox/src/fields/Buttons.php)
$value = $this->normalizeValue($this->defaultValue());
to this
$value = $this->normalizeValue($this->defaultValue(), $element);
Steps to reproduce
Create a new section and configure a new entry type
Add some entries to the new section
Create a new "Button" Button Box field and add a couple of selectable options
Add the new "Button Box" field to the entry type above
Click to open an existing entry for this section
Error message is displayed - and as a result cannot edit / update the entry.
Note: A similar issue occurs when adding or removing "Button Box" values/options from a Button Box field that is part of an existing entry and then returning to the entry to edit it.
Craft CMS version
5.1.1
Plugin version
5.0.0-beta-1
Multi-site?
Yes
Additional context
See Stack Trace below:
ArgumentCountError: Too few arguments to function craft\fields\BaseOptionsField::normalizeValue(), 1 passed in /craft/vendor/verbb/buttonbox/src/fields/Buttons.php on line 153 and exactly 2 expected in /craft/vendor/craftcms/cms/src/fields/BaseOptionsField.php:273
Stack trace:
Describe the bug
An "ArgumentCountError" occurs when adding a Button Box "Buttons" field to an existing entry
"ArgumentCountError: Too few arguments to function craft\fields\BaseOptionsField::normalizeValue(), 1 passed in /craft/vendor/verbb/buttonbox/src/fields/Buttons.php on line 153 and exactly 2 expected in /craft/vendor/craftcms/cms/src/fields/BaseOptionsField.php:273"
Buttons.php
BaseOptionsField.php
I believe the fix is to change this (on line 153 of /craft/vendor/verbb/buttonbox/src/fields/Buttons.php)
$value = $this->normalizeValue($this->defaultValue());
to this
$value = $this->normalizeValue($this->defaultValue(), $element);
Steps to reproduce
Note: A similar issue occurs when adding or removing "Button Box" values/options from a Button Box field that is part of an existing entry and then returning to the entry to edit it.
Craft CMS version
5.1.1
Plugin version
5.0.0-beta-1
Multi-site?
Yes
Additional context
See Stack Trace below:
ArgumentCountError: Too few arguments to function craft\fields\BaseOptionsField::normalizeValue(), 1 passed in /craft/vendor/verbb/buttonbox/src/fields/Buttons.php on line 153 and exactly 2 expected in /craft/vendor/craftcms/cms/src/fields/BaseOptionsField.php:273 Stack trace:
0 /craft/vendor/verbb/buttonbox/src/fields/Buttons.php(153): craft\fields\BaseOptionsField->normalizeValue()
1 /craft/vendor/craftcms/cms/src/base/Field.php(592): verbb\buttonbox\fields\Buttons->inputHtml()
2 /craft/vendor/craftcms/cms/src/fieldlayoutelements/CustomField.php(372): craft\base\Field->getInputHtml()
3 /craft/vendor/craftcms/cms/src/fieldlayoutelements/BaseField.php(349): craft\fieldlayoutelements\CustomField->inputHtml()
4 /craft/vendor/craftcms/cms/src/fieldlayoutelements/CustomField.php(324): craft\fieldlayoutelements\BaseField->formHtml()
5 /craft/vendor/craftcms/cms/src/web/View.php(1669): craft\fieldlayoutelements\CustomField->craft\fieldlayoutelements{closure}()
6 /craft/vendor/craftcms/cms/src/fieldlayoutelements/CustomField.php(323): craft\web\View->namespaceInputs()
7 /craft/vendor/craftcms/cms/src/models/FieldLayout.php(832): craft\fieldlayoutelements\CustomField->formHtml()
8 /craft/vendor/craftcms/cms/src/web/View.php(1663): craft\models\FieldLayout->craft\models{closure}()
9 /craft/vendor/craftcms/cms/src/models/FieldLayout.php(831): craft\web\View->namespaceInputs()
10 /craft/vendor/craftcms/cms/src/controllers/ElementsController.php(925): craft\models\FieldLayout->createForm()
11 /craft/vendor/craftcms/cms/src/controllers/ElementsController.php(398): craft\controllers\ElementsController->_prepareEditor()
12 [internal function]: craft\controllers\ElementsController->craft\controllers{closure}()
13 /craft/vendor/craftcms/cms/src/web/CpScreenResponseFormatter.php(125): call_user_func()
14 /craft/vendor/craftcms/cms/src/web/CpScreenResponseFormatter.php(50): craft\web\CpScreenResponseFormatter->_formatTemplate()
15 /craft/vendor/yiisoft/yii2/web/Response.php(1100): craft\web\CpScreenResponseFormatter->format()
16 /craft/vendor/craftcms/cms/src/web/Response.php(337): yii\web\Response->prepare()
17 /craft/vendor/yiisoft/yii2/web/Response.php(340): craft\web\Response->prepare()
18 /craft/vendor/yiisoft/yii2/base/Application.php(390): yii\web\Response->send()
19 /web/index.php(12): yii\base\Application->run()
20 {main}