src/Form/FormUtil.php
public function getWidgetFromAttributes(string $name, array $data, $value = null, string $dbName = '', string $table = '', DataContainer $dc = null, string $mode = ''): ? Widget
    {
        if ('' === $mode) {
            $mode = System::getContainer()->get('huh.utils.container')->isFrontend() ? 'FE' : 'BE';
        }

        if ('hidden' === $data['inputType']) {
            $mode = 'FE';
        }

        $mode = strtoupper($mode);
        $mode = \in_array($mode, ['FE', 'BE']) ? $mode : 'FE';
        $class = 'FE' === $mode ? $GLOBALS['TL_FFL'][$data['inputType']] : $GLOBALS['BE_FFL'][$data['inputType']];
        /** @var $widget Widget */
        $widget = $this->framework->getAdapter(Widget::class);

        if (empty($class) || !class_exists($class)) {
            return null;
        }

        return new $class($widget->getAttributesFromDca($data, $name, $value, $dbName, $table, $dc));
    }
public function getWidgetFromAttributes(string $name, array $data, $value = null, string $dbName = '', string $table = '', DataContainer $dc = null, string $mode = ''): ? Widget
    {
        if ('' === $mode) {
            $mode = System::getContainer()->get('huh.utils.container')->isFrontend() ? 'FE' : 'BE';
        }

        if ('hidden' === $data['inputType']) {
            $mode = 'FE';
        }

        $mode = strtoupper($mode);
        $mode = \in_array($mode, ['FE', 'BE']) ? $mode : 'FE';
        $class = 'FE' === $mode ? $GLOBALS['TL_FFL'][$data['inputType']] : $GLOBALS['BE_FFL'][$data['inputType']];
        /** @var $widget Widget */
        $widget = $this->framework->getAdapter(Widget::class);

        if (empty($class) || !class_exists($class)) {
            return null;
        }

        return new $class($widget->getAttributesFromDca($data, $name, $value, $dbName, $table, $dc));
    }
public function getWidgetFromAttributes ( string $ name , array $ data , $ value = null , string $ dbName = '' , string $ table = '' , DataContainer $ dc = null , string $ mode = '' ) : ? Widget { if ( '' === $ mode ) { $ mode = System :: getContainer ( ) -> get ( 'huh.utils.container' ) -> isFrontend ( ) ? 'FE' : 'BE' ; } if ( 'hidden' === $ data [ 'inputType' ] ) { $ mode = 'FE' ; } $ mode = strtoupper ( $ mode ) ; $ mode = \ in_array ( $ mode , [ 'FE' , 'BE' ] ) ? $ mode : 'FE' ; $ class = 'FE' === $ mode ? $ GLOBALS [ 'TL_FFL' ] [ $ data [ 'inputType' ] ] : $ GLOBALS [ 'BE_FFL' ] [ $ data [ 'inputType' ] ] ; /** @var $widget Widget */ $ widget = $ this -> framework -> getAdapter ( Widget :: class ) ; if ( empty ( $ class ) || ! class_exists ( $ class ) ) { return null ; } return new $ class ( $ widget -> getAttributesFromDca ( $ data , $ name , $ value , $ dbName , $ table , $ dc ) ) ; }
Get a new widget instance based on given attributes from a Data Container array.

@param string             $name   The field name in the form
@param array              $data   The field configuration array
@param mixed              $value  The field value
@param string             $dbName The field name in the database
@param string             $table  The table name in the database
@param DataContainer|null $dc     An optional DataContainer object
@param string             $mode   The contao mode, use FE or BE to get proper widget/form type

@return Widget|null The new widget based on given attributes
Get a new widget instance based on given attributes from a Data Container array .