-
Notifications
You must be signed in to change notification settings - Fork 15
Open
Labels
Description
Here's an idea for maybe a version 3: instead of having a definition file, I'd love to define the fields in a method of my custom controller. Something like this:
class FoobarController extends AbstractContentElementController implements CustomElementInterface
{
public function getResponse(ContentModel $model): Response
{
$config = StringUtil::deserialize($model->rsce_data);
}
public function getDefinnition(): array
{
return [
'fields' => [
'image' => [
'label' => ['Bild', 'Wählen Sie das Bild der Person.'],
'inputType' => 'fileTree',
'eval' => ['filesOnly' => true, 'mandatory' => true],
],
'name' => [
'label' => ['Name', 'Geben Sie den Namen der Person ein.'],
'inputType' => 'text',
'eval' => ['mandatory' => true, 'tl_class' => 'w50'],
],
'position' => [
'label' => ['Position/Abteilung/Untertitel', 'Geben Sie eine Position, Abteilung oder Untertitel für die Person ein.'],
'inputType' => 'text',
'eval' => ['mandatory' => true, 'tl_class' => 'w50'],
],
],
];
}
}we could also have a custom abstract controller or a trait that would deserialize the data and/or pass it to the template. The advantage is that I could use any template name, including Twig namespaces and overrides, and I would still have a real controller class if I need to do more stuff with the fields config 😎
Reactions are currently unavailable