Build Hidden fields based on the URL parameters
@param $currentField
@return string
429856
public function buildQueryInputs($currentField)
    {
        $request = $this->requestStack->getCurrentRequest();
        $fields = '';
        foreach ($request->query->all() as $field => $value) {
            // Exclude the current field and the PAGE parameter
            if($field !== $currentField && $field !== 'page'){
                $fields .= sprintf('<input type="hidden" name="%s" value="%s">', $field, $value);
            }
        }

        return $fields;
    }
1079009
public function renderFields()
    {
        $result = '';
        foreach ($this->fields as $field => $value) {
            $result .= '<input type="hidden" name="' . $field . '" value="' . $value . '"/>' . "\r\n";
        }

        return $result;
    }
1150442
protected function getAddressFieldValue($field)
    {
        if ($field instanceof \Closure) {
            return call_user_func($field, $this);
        }

        if (is_array($field)) {
            return $this->getRelationalField($field);
        }

        return $this->{$field};
    }
1153137
public function getCMSFields()
    {
        $this->beforeUpdateCMSFields(function (FieldList $fields) {
            if ($this->exists()) {
                // Add a GridField for domains to a new tab if the subsite has already been created
                $fields->addFieldsToTab('Root.Domains', [
                    GridField::create(
                        'Domains',
                        '',
                        $this->Domains(),
                        GridFieldConfig_RecordEditor::create(10)
                    )
                ]);
            }

            // Remove the default scaffolded blacklist field, we replace it with a checkbox set field
            // in a wrapper further down. The RedirectURL field is currently not in use.
            $fields->removeByName(['PageTypeBlacklist', 'RedirectURL']);

            $fields->addFieldToTab('Root.Main', DropdownField::create(
                'Language',
                $this->fieldLabel('Language'),
                Injector::inst()->get(IntlLocales::class)->getLocales()
            ), 'DefaultSite');

            $fields->addFieldsToTab('Root.Main', [
                ToggleCompositeField::create(
                    'PageTypeBlacklistToggle',
                    _t(__CLASS__ . '.PageTypeBlacklistField', 'Disallow page types?'),
                    [
                        CheckboxSetField::create('PageTypeBlacklist', '', $this->getPageTypeMap())
                    ]
                )->setHeadingLevel(4),
                HiddenField::create('ID', '', $this->ID),
                HiddenField::create('IsSubsite', '', 1)
            ]);

            // If there are any themes available, add the dropdown
            $themes = $this->allowedThemes();
            if (!empty($themes)) {
                $fields->addFieldToTab(
                    'Root.Main',
                    DropdownField::create('Theme', $this->fieldLabel('Theme'), $this->allowedThemes(), $this->Theme)
                        ->setEmptyString(_t(__CLASS__ . '.ThemeFieldEmptyString', '-')),
                    'PageTypeBlacklistToggle'
                );
            }

            // Targetted by the XHR PJAX JavaScript to reload the subsite list in the CMS
            $fields->fieldByName('Root.Main')->addExtraClass('subsite-model');

            // We don't need the Groups many many tab
            $fields->removeByName('Groups');

            // Rename the main tab to configuration
            $fields->fieldByName('Root.Main')->setTitle(_t(__CLASS__ . '.ConfigurationTab', 'Configuration'));
        });

        return parent::getCMSFields();
    }
707781
public function currentHost() : string
    {
        $url = $this->request->getUri();
        $parts = parse_url($url);
        unset($parts['query'], $parts['fragment'], $parts['path']);
        return http_build_url($parts);
    }
1274761
protected function getFormFields()
    {
        $request = $this->getRequest();
        if ($request->getVar('BackURL')) {
            $backURL = $request->getVar('BackURL');
        } else {
            $backURL = $request->getSession()->get('BackURL');
        }

        $label = Member::singleton()->fieldLabel(Member::config()->get('unique_identifier_field'));
        $fields = FieldList::create(
            HiddenField::create("AuthenticationMethod", null, $this->getAuthenticatorClass(), $this),
            // Regardless of what the unique identifer field is (usually 'Email'), it will be held in the
            // 'Email' value, below:
            // @todo Rename the field to a more generic covering name
            $emailField = TextField::create("Email", $label, null, null, $this),
            PasswordField::create("Password", _t('SilverStripe\\Security\\Member.PASSWORD', 'Password'))
        );
        $emailField->setAttribute('autofocus', 'true');

        if (Security::config()->get('remember_username')) {
            $emailField->setValue($this->getSession()->get('SessionForms.MemberLoginForm.Email'));
        } else {
            // Some browsers won't respect this attribute unless it's added to the form
            $this->setAttribute('autocomplete', 'off');
            $emailField->setAttribute('autocomplete', 'off');
        }
        if (Security::config()->get('autologin_enabled')) {
            $fields->push(
                CheckboxField::create(
                    "Remember",
                    _t('SilverStripe\\Security\\Member.KEEPMESIGNEDIN', "Keep me signed in")
                )->setAttribute(
                    'title',
                    _t(
                        'SilverStripe\\Security\\Member.REMEMBERME',
                        "Remember me next time? (for {count} days on this device)",
                        [ 'count' => RememberLoginHash::config()->uninherited('token_expiry_days') ]
                    )
                )
            );
        }

        if (isset($backURL)) {
            $fields->push(HiddenField::create('BackURL', 'BackURL', $backURL));
        }

        return $fields;
    }
634727
public function HiddenFields()
    {
        $hiddenFields = new FieldList();
        $dataFields = $this->dataFields();

        if ($dataFields) {
            foreach ($dataFields as $field) {
                if ($field instanceof HiddenField) {
                    $hiddenFields->push($field);
                }
            }
        }

        return $hiddenFields;
    }
600333
private function findHiddenField($field)
    {
        $node = $this->getSession()->getPage()->find(
            'xpath',
            strtr(
                ".//input[./@type = 'hidden'][(./@id = '%locator%' or ./@name = '%locator%')]",
                array('%locator%' => $field)
            )
        );
        if (null === $node) {
            throw new ElementNotFoundException($this->getSession(), 'hidden field', 'id|name', $field);
        }

        return $node;
    }
1184712
protected function generatePostFields () : string
	{
		$fieldsString = '';
		foreach($this->fields as $key => $value) $fieldsString .= $key.'='.$value.'&';
		return rtrim($fieldsString, '&');
	}
273962
public function build() : ActualField
    {
        $type                 = $this->type->withAll($this->attributes);
        $currentProcessedType = $type->getProcessedPhpType();
        $customerProcessors   = [];

        foreach ($this->customProcessorCallbacks as $callback) {
            /** @var IFieldProcessor $processor */
            $processor = $callback($currentProcessedType, $type, $this->initialValue);

            $customerProcessors[] = $processor;
            $currentProcessedType = $processor->getProcessedType();
        }

        return new ActualField(
            $this->name,
            $this->label,
            $type,
            $customerProcessors,
            $this->initialValue
        );
    }
1166760
protected function generateHidden($options, $currentValue)
    {
        $value = is_null($currentValue) ? $options['value'] : $currentValue;

        unset($options["id"]);
        unset($options["value"]);

        if (!array_key_exists("type", $options)) {
            $options["type"] = "hidden";
        }

        if (is_array($value)) {
            $returnHtml = "";
            foreach ($value as $key => $val) {
                $returnHtml .= sprintf('<input %s value="%s">', $this->arrayToHtmlAttributes($options), $val);
            }
            return $returnHtml;
        } else {
            return sprintf('<input %s value="%s">', $this->arrayToHtmlAttributes($options), $value);
        }
    }
407580
public function getUrlFromRouteName(
        $locale, $defaultLocale, $transKey, $attributes = [], $defaultHidden = false, $showHiddenLocale = false
    ) {
        if ( ! is_string($locale))
            $locale = $defaultLocale;

        $url = '';

        if ( ! ($locale === $defaultLocale && $defaultHidden) || $showHiddenLocale)
            $url = '/'.$locale;

        if ($this->hasTranslation($transKey, $locale))
            $url = Url::substituteAttributes($attributes, $url.'/'.$this->trans($transKey, $locale));

        return $url;
    }
1160484
public function getSortField($newValue, $currentValue = null)
    {
        $sortField = $currentValue;

        if ($newValue !== null) {
            $sortField = $this->sortConverter->hash2SortField($newValue);
        }

        return $sortField;
    }
1077606
private function buildFields() {
        $fields = array();
        /** @var ResultSet $results */
        $results = $this->getConfiguration()->getConnection()->query('SHOW COLUMNS FROM `' . $this->getTableName() . '`');
        $dbName = $this->getCurrentDatabaseName();
        while($result = $results->fetch()) {
            $result = (object)$result;
            $params = array($dbName, $this->getTableName(), $result->Field);
            /** @var ResultSet $informationResults */
            $informationResults = $this->getConfiguration()->getInformationSchemaConnection()->query(
                'SELECT * FROM `COLUMNS` WHERE TABLE_SCHEMA=? AND TABLE_NAME=? AND COLUMN_NAME=?',
                $params
            );
            /** @var \stdClass $informationResult */
            $informationResult = (object)$informationResults->fetch();
            $field = new Field($result, $this->getTableName(), $informationResult);
            switch($field->getType()) {
                case 'Date':
                    $this->getAbstractClass()->addUse($this->getConfiguration()->getDateClassName());
                    break;
                case 'DateTime':
                    $this->getAbstractClass()->addUse($this->getConfiguration()->getDateTimeClassName());
                    break;
            }
            $fields[] = $field;
        }
        usort(
            $fields,
            function (Field $fieldA, Field $fieldB) {
                return strcasecmp($fieldA->getShortName(), $fieldB->getShortName());
            }
        );
        $this->setFields($fields);
    }
1252340
public function getCMSFields()
    {
        $fields = parent::getCMSFields();

        $TeaserConfig = GridFieldConfig_RecordEditor::create();
        if ($this->LinkList()->Count() > 0) {
            $TeaserConfig->addComponent(new GridFieldOrderableRows());
        }

        $fields->removeByName(
            array(
                'ParentPageID',
                'ParentPage',
                'LinkLimit',
                'LinkList'
            )
        );

        $fields->addFieldsToTab(
            'Root.Main',
            array(
                TextareaField::create(
                    'Title'
                )->setRows(1),
                DropdownField::create(
                    'LinkType',
                    'Type',
                    array(
                        "currentchildren" => "List all sub pages of this page",
                        "children" => "Specify a page and list all its sub pages",
                        "specify" => "Specify each link"
                    )
                ),
                DisplayLogicWrapper::create(
                    TreeDropdownField::create(
                        'ParentPageID',
                        'Select a page',
                        'SiteTree'
                    )
                )->displayIf("LinkType")->isEqualTo("children")->end(),
                DisplayLogicWrapper::create(
                    NumericField::create(
                        'LinkLimit',
                        'Limit links'
                    )
                    ->setDescription("0 equals unlimited amount.")
                )->displayIf("LinkType")->isNotEqualTo("specify")->end(),
                DisplayLogicWrapper::create(
                    GridField::create(
                        'LinkList',
                        'Current Link(s)',
                        $this->LinkList(),
                        $TeaserConfig
                    )
                )->displayIf("LinkType")->isEqualTo("specify")->end()
            )
        );

        $this->extend('updateCMSFields', $fields);

        return $fields;
    }
860818
public function getCMSFields()
    {
        $commentField = $this->AllowHtml ? HTMLEditorField::class : TextareaField::class;
        $fields = new FieldList(
            $this
                ->obj('Created')
                ->scaffoldFormField($this->fieldLabel('Created'))
                ->performReadonlyTransformation(),
            TextField::create('Name', $this->fieldLabel('Name')),
            $commentField::create('Comment', $this->fieldLabel('Comment')),
            EmailField::create('Email', $this->fieldLabel('Email')),
            TextField::create('URL', $this->fieldLabel('URL')),
            FieldGroup::create(array(
                CheckboxField::create('Moderated', $this->fieldLabel('Moderated')),
                CheckboxField::create('IsSpam', $this->fieldLabel('IsSpam')),
            ))
                ->setTitle(_t(__CLASS__ . '.OPTIONS', 'Options'))
                ->setDescription(_t(
                    __CLASS__ . '.OPTION_DESCRIPTION',
                    'Unmoderated and spam comments will not be displayed until approved'
                ))
        );

        // Show member name if given
        if (($author = $this->Author()) && $author->exists()) {
            $fields->insertAfter(
                TextField::create('AuthorMember', $this->fieldLabel('Author'), $author->Title)
                    ->performReadonlyTransformation(),
                'Name'
            );
        }

        // Show parent comment if given
        if (($parent = $this->ParentComment()) && $parent->exists()) {
            $fields->push(new HeaderField(
                'ParentComment_Title',
                _t(__CLASS__ . '.ParentComment_Title', 'This comment is a reply to the below')
            ));
            // Created date
            // FIXME - the method setName in DatetimeField is not chainable, hence
            // the lack of chaining here
            $createdField = $parent
                ->obj('Created')
                ->scaffoldFormField($parent->fieldLabel('Created'));
            $createdField->setName('ParentComment_Created');
            $createdField->setValue($parent->Created);
            $createdField->performReadonlyTransformation();
            $fields->push($createdField);

            // Name (could be member or string value)
            $fields->push(
                $parent
                    ->obj('AuthorName')
                    ->scaffoldFormField($parent->fieldLabel('AuthorName'))
                    ->setName('ParentComment_AuthorName')
                    ->setValue($parent->getAuthorName())
                    ->performReadonlyTransformation()
            );

            // Comment body
            $fields->push(
                $parent
                    ->obj('EscapedComment')
                    ->scaffoldFormField($parent->fieldLabel(self::class))
                    ->setName('ParentComment_EscapedComment')
                    ->setValue($parent->Comment)
                    ->performReadonlyTransformation()
            );
        }

        $this->extend('updateCMSFields', $fields);
        return $fields;
    }
654212
public function GetActiveSettingAsHiddenInputField()
    {
        $sHTML = '';
        if (is_array($this->aActiveFilterData)) {
            reset($this->aActiveFilterData);
            foreach ($this->aActiveFilterData as $sItemName) {
                $sHTML .= '<input type="hidden" name="'.TGlobal::OutHTML($this->GetURLInputName()).'[]" value="'.TGlobal::OutHTML($sItemName).'" />';
            }
            reset($this->aActiveFilterData);
        }

        return $sHTML;
    }