Returns a dropdown filter with user configurable options in it

@return GridFieldDropdownFilter
180448
protected function getDropdownFilter()
    {
        /** @var GridFieldDropdownFilter $dropdownFilter */
        $dropdownFilter = Injector::inst()->create(
            GridFieldDropdownFilter::class,
            'addonFilter',
            'buttons-before-right',
            _t(__CLASS__ . '.ShowAllModules', 'Show all modules')
        );

        $dropdownFilter->addFilterOption(
            'supported',
            _t(__CLASS__ . '.FilterSupported', 'Supported modules'),
            ['Supported' => true]
        );
        $dropdownFilter->addFilterOption(
            'unsupported',
            _t(__CLASS__ . '.FilterUnsupported', 'Unsupported modules'),
            ['Supported' => false]
        );

        $this->extend('updateDropdownFilterOptions', $dropdownFilter);

        return $dropdownFilter;
    }
1217391
public function getCMSFields()
    {
        
        $this->beforeUpdateCMSFields(function ($fields) {
            $config = SiteConfig::current_site_config();

            $fields->removeByName("Customisation");

            $fields->addFieldToTab(
                "Root.Main",
                ReadonlyField::create("Key"),
                "Title"
            );

            $fields->addFieldToTab(
                "Root.Main",
                DropdownField::create(
                    "TaxID",
                    $this->fieldLabel("TaxID"),
                    $config->TaxRates()->map()
                ),
                "Weight"
            );

            $fields->addFieldsToTab(
                "Root.Description",
                [
                    HTMLEditorField::create("Content")
                        ->addExtraClass("stacked")
                ]
            );

            // Change unlink button to remove on customisation
            $custom_field = $fields->dataFieldByName("Customisations");

            if ($custom_field) {
                $config = $custom_field->getConfig();
                $config
                    ->removeComponentsByType(GridFieldDeleteAction::class)
                    ->removeComponentsByType(GridFieldDataColumns::class)
                    ->removeComponentsByType(GridFieldEditButton::class)
                    ->removeComponentsByType(GridFieldAddNewButton::class)
                    ->removeComponentsByType(GridFieldAddExistingAutocompleter::class)
                    ->addComponents(
                        new GridFieldEditableColumns(),
                        new GridFieldAddNewInlineButton(),
                        new GridFieldEditButton(),
                        new GridFieldDeleteAction()
                    );
                
                    $custom_field->setConfig($config);
            }
        });

        return parent::getCMSFields();
    }
479688
public function getFieldEditorGrid()
    {
        Requirements::javascript('silverstripe/userforms:client/dist/js/userforms-cms.js');

        $fields = $this->owner->Fields();

        $this->createInitialFormStep(true);

        $editableColumns = new GridFieldEditableColumns();
        $fieldClasses = singleton(EditableFormField::class)->getEditableFieldClasses();
        $editableColumns->setDisplayFields([
            'ClassName' => function ($record, $column, $grid) use ($fieldClasses) {
                if ($record instanceof EditableFormField) {
                    return $record->getInlineClassnameField($column, $fieldClasses);
                }
            },
            'Title' => function ($record, $column, $grid) {
                if ($record instanceof EditableFormField) {
                    return $record->getInlineTitleField($column);
                }
            }
        ]);

        $config = GridFieldConfig::create()
            ->addComponents(
                $editableColumns,
                new GridFieldButtonRow(),
                (new GridFieldAddClassesButton(EditableTextField::class))
                    ->setButtonName(_t(__CLASS__.'.ADD_FIELD', 'Add Field'))
                    ->setButtonClass('btn-primary'),
                (new GridFieldAddClassesButton(EditableFormStep::class))
                    ->setButtonName(_t(__CLASS__.'.ADD_PAGE_BREAK', 'Add Page Break'))
                    ->setButtonClass('btn-secondary'),
                (new GridFieldAddClassesButton([EditableFieldGroup::class, EditableFieldGroupEnd::class]))
                    ->setButtonName(_t(__CLASS__.'.ADD_FIELD_GROUP', 'Add Field Group'))
                    ->setButtonClass('btn-secondary'),
                $editButton = new GridFieldEditButton(),
                new GridFieldDeleteAction(),
                new GridFieldToolbarHeader(),
                new GridFieldOrderableRows('Sort'),
                new GridFieldDetailForm()
            );

        $editButton->removeExtraClass('grid-field__icon-action--hidden-on-hover');

        $fieldEditor = GridField::create(
            'Fields',
            '',
            $fields,
            $config
        )->addExtraClass('uf-field-editor');

        return $fieldEditor;
    }
1187040
protected function getTemplate()
    {
        $filter_tpl = $this->config->getTemplate();
        $grid_tpl = $this->grid->getConfig()->getTemplate();
        return str_replace('*.', "$grid_tpl.filters.", $filter_tpl);
    }
209973
protected function getOptionListFromJasper()
    {
        $optionList = array();

        //Get the options from the jasper server
        $inputControlStateArray = JasperHelper::convertInputControlState($this->state);

        foreach ($inputControlStateArray["option"] as $key => $option) {
            //Create an option instance for each option
            $optionList[] = new Option (
                $option["value"],
                $option["label"],
                $option["selected"]
            );
        }

        //Return the options list
        return $optionList;
    }
534184
protected function getDropdownOptions()
    {
        $values = $this->getDropdownValues();
        $labels = $this->getDropdownLabels();

        // Make sure that labels are set for each value
        foreach ($values as $value) {
            if (isset($labels[ $value ])) continue;

            $labels[ $value ] = $value;
        }

        return array_intersect_key($labels, array_flip($values));
    }
87641
public static function dropdown()
    {
        // get all records from database and generate
        static $dropdown;
        if ($dropdown === null) {
            $models = static::find()->all();
            foreach ($models as $model) {
                $dropdown[$model->id] = $model->name;
            }
        }
        return $dropdown;
    }
133568
protected function getRulesConfig()
    {
        if (!$this->getFormParent()) {
            return null;
        }
        $formFields = $this->getFormParent()->Fields();

        $config = GridFieldConfig::create()
            ->addComponents(
                new GridFieldButtonRow('before'),
                new GridFieldToolbarHeader(),
                new GridFieldAddNewInlineButton(),
                new GridFieldDeleteAction(),
                $columns = new GridFieldEditableColumns()
            );

        $columns->setDisplayFields(array(
            'ConditionFieldID' => function ($record, $column, $grid) use ($formFields) {
                return DropdownField::create($column, false, $formFields->map('ID', 'Title'));
            },
            'ConditionOption' => function ($record, $column, $grid) {
                $options = EmailRecipientCondition::config()->condition_options;
                return DropdownField::create($column, false, $options);
            },
            'ConditionValue' => function ($record, $column, $grid) {
                return TextField::create($column);
            }
        ));

        return $config;
    }
325937
public function getFilter()
    {
        if (null == $this->filter) {
            $this->filter = new Filter([
                'serviceLocator' => $this->getServiceLocator(),
                'id'             => $this->getId(),
            ]);
        }

        return $this->filter;
    }
674433
public function getCMSFields() {
        $langGridConfig=GridFieldConfig_RecordEditor::create(30);
        $langGridConfig->getComponentByType('GridFieldDetailForm')->setItemRequestClass('CodeBankGridField_ItemRequest');
        $langGridConfig->getComponentByType('GridFieldDataColumns')->setFieldCasting(array(
                                                                                            'UserLanguage'=>'Boolean->Nice',
                                                                                            'Hidden'=>'Boolean->Nice'
                                                                                        ));
        
        $packageGridConfig=GridFieldConfig_RecordEditor::create(30);
        $packageGridConfig->addComponent(new ExportPackageButton());
        $packageGridConfig->getComponentByType('GridFieldDetailForm')->setItemRequestClass('CodeBankGridField_ItemRequest')->setItemEditFormCallback(function(Form $form, GridFieldDetailForm_ItemRequest $itemRequest) {
                                                                                                    Requirements::javascript(CB_DIR.'/javascript/SnippetPackages.ItemEditForm.js');
                                                                                                    
                                                                                                    if($form->getRecord() && $form->getRecord()->ID>0) {
                                                                                                        $form->Actions()->push(FormAction::create('doExportPackage', _t('CodeBank.EXPORT', '_Export'))->setForm($form));
                                                                                                    }
                                                                                                    
                                                                                                    $form->addExtraClass('CodeBankPackages');
                                                                                                });
        
        if(Permission::check('ADMIN')) {
            $fields=new FieldList(
                                new TabSet('Root',
                                        new Tab('Main', _t('CodeBankConfig.MAIN', '_IP Message'),
                                                HtmlEditorField::create('IPMessage', _t('CodeBankConfig.IP_MESSAGE', '_Intellectual Property Message'))->addExtraClass('stacked')
                                            ),
                                        new Tab('Languages', _t('CodeBankConfig.LANGUAGES', '_Languages'),
                                                new GridField('Languages', _t('CodeBankConfig.LANGUAGES', '_Languages'), SnippetLanguage::get(), $langGridConfig)
                                            ),
                                        new Tab('Packages', _t('CodeBank.PACKAGES', '_Packages'),
                                                new GridField('Packages', _t('CodeBankConfig.MANAGE_PACKAGES', '_Manage Packages'), SnippetPackage::get(), $packageGridConfig)
                                            )
                                    )
                            );
        }else {
            $fields=new FieldList(
                                new TabSet('Root',
                                                new Tab('Packages', _t('CodeBank.PACKAGES', '_Packages'),
                                                        new GridField('Packages', _t('CodeBankConfig.MANAGE_PACKAGES', '_Manage Packages'), SnippetPackage::get(), $packageGridConfig)
                                                    )
                                            )
                            );
        }
        
        return $fields;
    }
595253
protected function filters()
    {
        $where = $this->initFilters();

        $gf = $this->globalFilter();
        $where .= (empty($where) ? $gf : (empty($gf) ? '' : ' AND '.$gf));

        $gf = $this->individualColumnFilters();
        $where .= (empty($where) ? $gf : (empty($gf) ? '' : ' AND '.$gf));

        return $where;
    }
914042
public function field()
    {
        $yesOption = '<option value="1"'.($this->value === 1 ? ' selected="selected"' : null).'>'.
            trans('panel::global.yes').'</option>';
        $noOption = '<option value="0"'.($this->value === 0 ? ' selected="selected"' : null).'>'.
            trans('panel::global.no').'</option>';

        $input = new HTMLBrick('select', $yesOption.$noOption, [
            'id'   => $this->id,
            'name' => $this->name,
        ]);
        $input->addClass('form-control');

        return $input;
    }
945653
public function getListFilter()
    {
        if ($this->_aListFilter === null) {
            $this->_aListFilter = \OxidEsales\Eshop\Core\Registry::getConfig()->getRequestParameter("where");
        }

        return $this->_aListFilter;
    }
653397
public function getOptions()
    {
        $selectedValues = $this->getValueArray();
        $defaultItems = $this->getDefaultItems();
        $disabledItems = $this->getDisabledItems();

        // Generate list of options to display
        $odd = false;
        $formID = $this->ID();
        $options = new ArrayList();
        foreach ($this->getSource() as $itemValue => $title) {
            $itemID = Convert::raw2htmlid("{$formID}_{$itemValue}");
            $odd = !$odd;
            $extraClass = $odd ? 'odd' : 'even';
            $extraClass .= ' val' . preg_replace('/[^a-zA-Z0-9\-\_]/', '_', $itemValue);

            $itemChecked = in_array($itemValue, $selectedValues) || in_array($itemValue, $defaultItems);
            $itemDisabled = $this->isDisabled() || in_array($itemValue, $disabledItems);

            $options->push(new ArrayData(array(
                'ID' => $itemID,
                'Class' => $extraClass,
                'Name' => "{$this->name}[{$itemValue}]",
                'Value' => $itemValue,
                'Title' => $title,
                'isChecked' => $itemChecked,
                'isDisabled' => $itemDisabled,
            )));
        }
        $this->extend('updateGetOptions', $options);
        return $options;
    }
1017716
public function getGridConfig()
	{
		$config = new Zend_Config(array(), true);
		if(Zend_Registry::isRegistered('config') && isset(Zend_Registry::get('config')->dataGrid))
		{
			$config->merge(Zend_Registry::get('config')->dataGrid);
		}
		$config->merge(new Zend_Config($this->_settings));

		foreach($config as $optionName => $optionValue)
		{
			if(!isset($optionValue->title) && isset($optionValue->label))
			{
				$config->$optionName->title = $optionValue->label;
				unset($config->$optionName->label);
			}
			if(isset($optionValue->visible) && !$optionValue->visible)
			{
				$config->$optionName->hidden = true;
			}

			if(isset($optionValue->type))
			{
				if(!isset($config->$optionName->jqg))
				{
					$config->$optionName->jqg = new Zend_Config(array(), true);
				}
				switch($optionValue->type)
				{
					case "select":
						$multiOptions = array();
						$multiOptions[''] = 'LABEL_ALL';
						$multiOptions += $config->$optionName->multiOptions->toArray();

						$multiOptions = array_map(function($key, $row){
							$translate = App_Translate::getInstance();
							return $key.':'.$translate->translate($row);
						}, array_keys($multiOptions), $multiOptions);
						ksort($multiOptions);

						$multiOptions = implode(';', $multiOptions);

						$config->$optionName->jqg->merge(new Zend_Config(array(
							'stype' => 'select',
							'searchoptions' => array(
								'sopt' => array(
									'eq'
								),
								'value' => $multiOptions
							),
							'searchType' => '='
						)), true);
						break;
					case "date":
						$config->$optionName->merge(new Zend_Config(array(
							'sorttype' => 'date',
							'format'   => array(
								'date',
								array(
									'date_format' => Zend_Date::DATE_MEDIUM
								)
							),
							'jqg'      => array(
								'searchoptions' => array(
									'dataInit' => new Zend_Json_Expr('function(el){
											jQuery(el).datepicker({
													dateFormat: "yy-mm-dd",
													onSelect: function(dateText, inst){
															jQuery(el).parents(".ui-jqgrid").find(".ui-jqgrid-btable").get(0).triggerToolbar();
													}
											});
									}')
								)
							)
						)), true);

						if(!isset($config->$optionName->defaultvalue))
						{
							$config->$optionName->defaultvalue = null;
						}
						break;
					case "datetime":
						$config->$optionName->merge(new Zend_Config(array(
							'sorttype' => 'date',
							'format'   => array(
								'date',
								array(
									'date_format' => Zend_Date::DATETIME_SHORT
								)
							),
							'jqg'      => array(
								'searchoptions' => array(
									'dataInit' => new Zend_Json_Expr('function(el){
											jQuery(el).datetimepicker({
													dateFormat: "yy-mm-dd",
													timeFormat: "hh:mm",
													onSelect: function(dateText, inst){
															jQuery(el).parents(".ui-jqgrid").find(".ui-jqgrid-btable").get(0).triggerToolbar();
													}
											});
									}')
								)
							)
						)), true);

						if(!isset($config->$optionName->defaultvalue))
						{
							$config->$optionName->defaultvalue = null;
						}
						break;
					case "time":
						$config->$optionName->merge(new Zend_Config(array(
							'sorttype' => 'date',
							'format'   => array(
								'date',
								array(
									'date_format' => Zend_Date::TIME_SHORT
								)
							),
							'jqg'      => array(
								'searchoptions' => array(
									'dataInit' => new Zend_Json_Expr('function(el){
											jQuery(el).timepicker({
													timeFormat: "hh:mm",
													onSelect: function(dateText, inst){
															jQuery(el).parents(".ui-jqgrid").find(".ui-jqgrid-btable").get(0).triggerToolbar();
													}
											});
									}')
								)
							)
						)), true);

						if(!isset($config->$optionName->defaultvalue))
						{
							$config->$optionName->defaultvalue = null;
						}
						break;
					case "boolean":
					case "bool":
						$multiOptions = array(
							'' => 'LABEL_ALL',
							'0' => 'LABEL_NO',
							'1' => 'LABEL_YES'
						);
						$multiOptions = array_map(function($key, $row){
							$translate = App_Translate::getInstance();
							return $key.':'.$translate->translate($row);
						}, array_keys($multiOptions), $multiOptions);

						$multiOptions = implode(';', $multiOptions);

						$config->$optionName->merge(new Zend_Config(array(
							'width' => 30,
							'align' => 'center',
							'jqg' => array(
								'stype' => 'select',
								'searchoptions' => array(
									'sopt' => array(
										'eq'
									),
									'value' => $multiOptions
								)
							),
							'searchType' => '='
						)), true);

						if(!isset($config->$optionName->helper) && !isset($config->$optionName->callback))
						{
							$config->$optionName->merge(new Zend_Config(array(
								'jqg' => array(
									'formatter' => 'checkbox'
								)
							)), true);
						}

						break;
					case "int":
						$config->$optionName->merge(new Zend_Config(array(
							'searchType' => '='
						)), true);

						break;
					default:
						debug_assert(false !== array_search($optionValue->type, self::$types), "Unknown Grid Cell Type `{$optionValue->type}`");
				}
			}

		}

		return $config;
	}
854957
protected function getOptions()
	{
		$options = array();

		$select = new HtmlSelect;

		// Try to inject the text object into the field
		try
		{
			$select->setText($this->getText());
		}
		catch (\RuntimeException $exception)
		{
			// A Text object was not set, ignore the error and try to continue processing
		}

		/** @var \SimpleXMLElement $option */
		foreach ($this->element->children() as $option)
		{
			// Only add <option /> elements.
			if ($option->getName() != 'option')
			{
				continue;
			}

			// Create a new option object based on the <option /> element.
			$tmp = $select->option(
				(string) $option['value'], trim((string) $option), 'value', 'text', ((string) $option['disabled'] == 'true')
			);

			// Set some option attributes.
			$tmp->class = (string) $option['class'];

			// Set some JavaScript option attributes.
			$tmp->onclick = (string) $option['onclick'];

			// Add the option object to the result set.
			$options[] = $tmp;
		}

		reset($options);

		return $options;
	}
922626
protected function createComponentUserList(): DataGrid
	{
		$grid = $this->dataGridFactory->create();

		$grid->setDataSource($this->orm->users->findAll());

		$grid->addToolbarButton('add', 'cms.user.add')
			->setIcon('plus');

		$grid->addColumnText('username', 'cms.user.username')
			->setSortable()
			->setFilterText();

		$grid->addColumnText('firstName', 'cms.user.firstName')
			->setSortable()
			->setFilterText();

		$grid->addColumnText('surname', 'cms.user.surname')
			->setSortable()
			->setFilterText();

		$grid->addColumnText('email', 'cms.user.email')
			->setSortable()
			->setFilterText();

		$grid->addColumnText('roles', 'cms.permissions.roles', 'roles.id')
			->setRenderer(function (User $user) {
				$obj = new Html;
				$delimiter = '';
				foreach ($user->roles as $role) {
					$link = Html::el('a');
					$link->href = $this->link('Permissions:editRolePermissions', ['id' => $role->id]);
					$link->addText($role->title);
					$obj->addHtml($delimiter . $link);
					$delimiter = ', ';
				}
				return $obj;
			})
			->setFilterSelect(['' => $this->translate('form.none')] + $this->orm->aclRoles->fetchPairs($this->user->isAllowed('dockbar.settings.permissions.superadmin', 'view')));

		$active = [
			'' => 'form.none',
			1 => 'default.active',
			0 => 'default.deactive'
		];
		$state = $grid->addColumnStatus('active', 'cms.user.state');
		$state->setFilterSelect($active)
			->setTranslateOptions();
		$state->addOption(1, 'default.active')
			->setClass('btn-success');
		$state->addOption(0, 'default.deactive')
			->setClass('btn-danger');
		$state->onChange[] = [$this, 'setState'];

		if ($this['tryUser']->isAllowed()) {
			$grid->addAction('tryUser', null, 'tryUser!')
				->addAttributes(['target' => '_blank'])
				->setIcon('user')
				->setTitle('cms.user.tryUser');
		}

		$grid->addAction('edit', null)
			->setIcon('pencil')
			->setTitle('cms.user.edit');

		$grid->addAction('changePassword', null)
			->setIcon('wrench')
			->setTitle('cms.user.changePassword');

		$grid->addAction('delete', null, 'delete!')
			->setIcon('trash')
			->setTitle('default.delete')
			->setClass('btn btn-xs btn-danger ajax')
			->setConfirm(function (User $user) {
				return $this->translate('default.confirmDelete', null, ['name' => $user->fullName]);
			});

		$grid->addGroupAction('default.activate')->onSelect[] = [$this, 'activateUsers'];
		$grid->addGroupAction('default.deactivate')->onSelect[] = [$this, 'deactivateUsers'];
		$grid->addGroupAction('default.delete')->onSelect[] = [$this, 'deleteUsers'];

		return $grid;
	}