Extend controller form using yaml file

Hi. I have to extend a backend controller with a pretty elaborated form. Is there a way to feed the addTabFields or addFields function with a form yaml file like in the regular form controller behaviour?

1 Like

The test plugin has an example of this, it even adds a prefix to the fields. Here is the code for it:

public function formExtendFields($form)
{
    $config = $this->makeConfig('$/october/test/models/meta/fields.yaml');

    foreach ($config->fields as $field => $options) {
        $form->addTabFields([
            'meta['.$field.']' => $options + ['tab' => 'Meta']
        ]);
    }
}

Easily adapted to

public function formExtendFields($form)
{
    $config = $this->makeConfig('$/october/test/models/meta/fields.yaml');

    $form->addTabFields($config->fields);
}
2 Likes