MetaModels\Filter\Setting\Simple::prepareFrontendFilterWidget PHP Method

prepareFrontendFilterWidget() protected method

The returning array will hold the following keys: * class - The CSS classes for the widget. * label - The label text for the widget. * formfield - The parsed default widget object for this filter setting. * raw - The widget information that was used for rendering "formfield" as raw array (this means prior calling prepareForWidget()). * urlparam - The URL parameter used for this widget. * options - The filter options available to be used in selects etc. see prepareFrontendFilterOptions for details on the contained array. * autosubmit - True if the frontend filter shall perform auto form submitting, false otherwise. * urlvalue - The current value selected in the filtersetting. Will use "urlvalue" from $arrWidget with fallback to the value of the url param in the filter url.
protected prepareFrontendFilterWidget ( array $arrWidget, array $arrFilterUrl, array $arrJumpTo, MetaModels\FrontendIntegration\FrontendFilterOptions $objFrontendFilterOptions ) : array
$arrWidget array The widget information to use for generating.
$arrFilterUrl array The filter url parameters to use.
$arrJumpTo array The jumpTo page to use for URL generating - if empty, the current frontend page will get used.
$objFrontendFilterOptions MetaModels\FrontendIntegration\FrontendFilterOptions The options to use.
return array
    protected function prepareFrontendFilterWidget($arrWidget, $arrFilterUrl, $arrJumpTo, FrontendFilterOptions $objFrontendFilterOptions)
    {
        $strClass = $GLOBALS['TL_FFL'][$arrWidget['inputType']];
        // No widget? no output! that's it.
        if (!$strClass) {
            return array();
        }
        // Determine current value.
        $arrWidget['value'] = isset($arrFilterUrl[$arrWidget['eval']['urlparam']]) ? $arrFilterUrl[$arrWidget['eval']['urlparam']] : null;
        $dispatcher = $this->getEventDispatcher();
        $event = new GetAttributesFromDcaEvent($arrWidget, $arrWidget['eval']['urlparam']);
        $dispatcher->dispatch(ContaoEvents::WIDGET_GET_ATTRIBUTES_FROM_DCA, $event);
        if ($objFrontendFilterOptions->isAutoSubmit() && TL_MODE == 'FE') {
            $GLOBALS['TL_JAVASCRIPT']['metamodels'] = 'system/modules/metamodels/assets/js/metamodels.js';
        }
        /** @var \Widget $objWidget */
        $objWidget = new $strClass($event->getResult());
        $this->validateWidget($objWidget, $arrWidget['value']);
        $strField = $objWidget->generateWithError();
        return array('class' => sprintf('mm_%s %s%s%s', $arrWidget['inputType'], $arrWidget['eval']['urlparam'], $arrWidget['value'] !== null ? ' used' : ' unused', $objFrontendFilterOptions->isAutoSubmit() ? ' submitonchange' : ''), 'label' => $objWidget->generateLabel(), 'formfield' => $strField, 'raw' => $arrWidget, 'urlparam' => $arrWidget['eval']['urlparam'], 'options' => $this->prepareFrontendFilterOptions($arrWidget, $arrFilterUrl, $arrJumpTo, $objFrontendFilterOptions->isAutoSubmit()), 'count' => isset($arrWidget['count']) ? $arrWidget['count'] : null, 'showCount' => $objFrontendFilterOptions->isShowCountValues(), 'autosubmit' => $objFrontendFilterOptions->isAutoSubmit(), 'urlvalue' => array_key_exists('urlvalue', $arrWidget) ? $arrWidget['urlvalue'] : $arrWidget['value'], 'errors' => $objWidget->hasErrors() ? $objWidget->getErrors() : array());
    }