madeyourday/contao-rocksolid-custom-elements

New DCA Picker?

Closed this issue · 3 comments

ngdot commented

Contao Version: 4.9.12

Hi, if I want to use the new picker as inputType for a custom element, I'm getting the error:

The table name must not be empty

[2021-03-03 14:52:14] request.CRITICAL: Uncaught PHP Exception Exception: "The table name must not be empty" at /**/web/vendor/contao/core-bundle/src/Resources/contao/library/Contao/DcaLoader.php line 50 {"exception":"[object] (Exception(code: 0): The table name must not be empty at /**/web/vendor/contao/core-bundle/src/Resources/contao/library/Contao/DcaLoader.php:50)"} []

This is my code:

'foo' => array(
	'label' => array(
		'Foo', 
		''
	),
	'inputType' => 'picker',
	'eval' => array(
		'tl_class' => 'clr w50'
	),
)

I also tried adding 'foreignKey' => 'tl_content.id' and 'relation' => array('type'=>'hasOne', 'load'=>'lazy', 'table'=>'tl_content') same error.

It seems that RSCE doesnt support the new dca picker, any ideas or future plans?

ausi commented

You need to set eval.context because the relations are stored statically for each DCA and can therefore not be retrieved for “dynamic” fields: 'eval' => ['context' => 'dc.tl_content']

But it looks like there is an issue in the core too, because the value doesn’t get saved and the preview is not properly rendered.

These lines https://github.com/contao/contao/blob/29f2d850957bf626a9304423962f49fb706abd0f/core-bundle/src/Resources/contao/widgets/Picker.php#L177-L182 need to be replaced with something like this IMO:

if (substr($this->context ?? '', 0, 3) === 'dc.') 
{
	$strRelatedTable = substr($this->context, 3);
}
else 
{
	$strRelatedTable = $this->getRelatedTable();
}

if (!$strRelatedTable)
{
	return array_combine((array) $this->varValue, (array) $this->varValue);
}
ngdot commented

Yep, that's it! Works fine :) Thanks.

ausi commented

Should get fixed by contao/contao#2837