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
        ]));
    }
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
        ]));
    }
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 ] ) ) ; }
Create a plugin element.

Simplifies the creation of the associated FlexForm by allowing you to pass
$attrs['form'], containing a of sheet names to flex form config. For example:

$attrs['form'] => [
'Sheet1' => [
'settings.title' => 'An Example'
]
]

@param  int  $pid
@param  string  $plugin  Plugin name, of the form vendorextension_pluginname
@param  array  $attrs
@return  int|null
Create a plugin element .