Argument 1 passed to `formatShowData` must be of the type array, string given
fritzmg opened this issue · 2 comments
fritzmg commented
If you have a custom element like this:
return [
'label' => ['Foobar', ''],
'types' => ['content'],
'contentCategory' => 'texts',
'standardFields' => ['cssID'],
'wrapper' => ['type' => 'none'],
'fields' => [
'elements' => [
'label' => ['Elements'],
'elementLabel' => '%s. element',
'inputType' => 'list',
'minItems' => 1,
'fields' => [
'number' => [
'label' => ['Number', 'Lorem ipsum.'],
'inputType' => 'text',
'eval' => ['tl_class' => 'clr w50', 'size' => 3, 'multiple' => true, 'maxlength' => 255],
],
'text' => [
'label' => ['Text', 'Dolor sit amet.'],
'inputType' => 'text',
'eval' => ['rte' => 'tinyMCE', 'tl_class' => 'clr'],
],
],
],
],
];
and you create a content element with it, the following error will occur when clicking ℹ️
TypeError:
Argument 1 passed to MadeYourDay\RockSolidCustomElements\CustomElements::formatShowData() must be of the type array, string given, called in vendor\madeyourday\contao-rocksolid-custom-elements\src\CustomElements.php on line 193
at vendor\madeyourday\contao-rocksolid-custom-elements\src\CustomElements.php:180
at MadeYourDay\RockSolidCustomElements\CustomElements::formatShowData('20', array(), '1. element › number 1 › ', 'elements[0]->number[0]->')
(vendor\madeyourday\contao-rocksolid-custom-elements\src\CustomElements.php:193)
at MadeYourDay\RockSolidCustomElements\CustomElements::formatShowData(array('number' => array('20'), 'text' => 'Test'), …
(vendor\madeyourday\contao-rocksolid-custom-elements\src\CustomElements.php:193)
at MadeYourDay\RockSolidCustomElements\CustomElements::formatShowData(…
(vendor\madeyourday\contao-rocksolid-custom-elements\src\CustomElements.php:175)
at MadeYourDay\RockSolidCustomElements\CustomElements::onshowCallback(…
(vendor\contao\core-bundle\src\Resources\contao\drivers\DC_Table.php:552)
at Contao\DC_Table->show()
(vendor\contao\core-bundle\src\Resources\contao\classes\Backend.php:642)
at Contao\Backend->getBackendModule('article', null)
(vendor\contao\core-bundle\src\Resources\contao\controllers\BackendMain.php:169)
at Contao\BackendMain->run()
(vendor\contao\core-bundle\src\Controller\BackendController.php:48)
at Contao\CoreBundle\Controller\BackendController->mainAction()
(vendor\symfony\http-kernel\HttpKernel.php:159)
at Symfony\Component\HttpKernel\HttpKernel->handleRaw(object(Request), 1)
(vendor\symfony\http-kernel\HttpKernel.php:81)
at Symfony\Component\HttpKernel\HttpKernel->handle(object(Request), 1, true)
(vendor\symfony\http-kernel\Kernel.php:201)
at Symfony\Component\HttpKernel\Kernel->handle(object(Request))
(web\index.php:31)
I think it's the text
input field with 'multiple' => 3
that causes this, though haven't looked into it in more detail yet.
ausi commented
I was not able to reproduce that. Your stack trace shows the data as
array('number' => array('20'), 'text' => 'Test')
but It should have been something like
array('number' => 'a:1:{i:0;s:2:"20";}', 'text' => 'Test')
instead.