Skip to content

Support RSCE definition in fragment controller #162

@aschempp

Description

@aschempp

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 😎

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions