donaldej11128
donaldej11128

I have been reading over the documentation and I cannot figure out how to make a simple form. I dont want to use the create or update actions, as I am trying to basically make a config screen for my plugin. I have made the appropriate xml files but it just gives me an exception saying that formInit() needs to be run.

donaldej11128
donaldej11128

Nevermind, I figured it out.

You just create a controller using the FormController like any other, but in an action where you need to use the form controller features, have to manually run initForm.

namespace Frontname\Plugin\Controllers;

use BackendMenu;
use Backend\Classes\Controller;

class Settings extends Controller {
    public $implement = [
        'Backend.Behaviors.FormController'
    ];

    public $formConfig = 'config_form.yaml';

    public $requiredPermissions = ['frontname.plugin.permission_name'];

    public function __construct() {
        parent::__construct();
        BackendMenu::setContext('Frontname.Plugin', 'plugin', 'controller');
    }

    public function index() {            
        $this -> initForm($this);  
        $this -> pageTitle = 'frontname.plugin::lang.controller.title';      
    }

}

Last updated

joaocosta.azores20952
joaocosta.azores20952

Were you trying to show a backend form instead of showing a list in backend?

1-3 of 3