public function createPlugin($pid, $plugin, $attrs = [])
    {
        if (isset($attrs['form'])) {
            $flexFormSheets = [];

            foreach ($attrs['form'] as $sheet => $setup) {
                $flexFormSheets[$sheet] = [];

                foreach ($setup as $key => $value) {
                    $flexFormSheets[$sheet][$key] = [
                        'vDEF' => $value
                    ];
                }
            }

            $attrs['pi_flexform'] = [
                'data' => []
            ];

            foreach ($flexFormSheets as $sheet => $setup) {
                $attrs['pi_flexform']['data'][$sheet] = [
                    'lDEF' => $setup
                ];
            }

            unset($attrs['form']);
        }

        return $this->create($pid, array_merge($attrs, [
            'CType' => 'list',
            'list_type' => $plugin
        ]));
    }