Save the current sites {@link FoxyStripeSetting} into the database.

@param $data
@param $form

@return \SilverStripe\Control\HTTPResponse
@throws \SilverStripe\Control\HTTPResponse_Exception
498596
public function save_foxystripe_setting($data, $form)
    {
        $config = FoxyStripeSetting::current_foxystripe_setting();
        $form->saveInto($config);
        try {
            $config->write();
        } catch (ValidationException $ex) {
            //$form->sessionMessage($ex->getResult()->getMessages(), 'bad');

            return $this->getResponseNegotiator()->respond($this->request);
        }
        $this->response->addHeader('X-Status', rawurlencode(_t('SilverStripe\\Admin\\LeftAndMain.SAVEDUP', 'Saved.')));

        return $form->forTemplate();
    }
1067053
public function doAddToList($data, /** @scrutinizer ignore-unused */ $form)
    {
        $className  = $this->gridField->list->dataClass;
        $controller = $this->getToplevelController();
        $form = $controller->EditForm();
        $return = array();

        if (isset($data['RecordIDs'])) {
            $ids = explode(",", $data['RecordIDs']);
        } else {
            $ids = array();
        }

        $list_id = (isset($data['ContactListID'])) ? $data['ContactListID'] : 0;
        $list = ContactList::get()->byID($list_id);
        
        try {
            foreach ($ids as $record_id) {
                if ($list_id) {
                    $record = DataObject::get_by_id($className, $record_id);
                    
                    if ($record->hasMethod("Lists")) {
                        $list->Contacts()->add($record);
                        $list->write();
                    }
                    
                    $return[] = $record->ID;
                }
            }
        } catch (\Exception $e) {
            $form->sessionMessage(
                $e->getMessage(),
                ValidationResult::TYPE_ERROR
            );
                
            $responseNegotiator = new PjaxResponseNegotiator(array(
                'CurrentForm' => function () use (&$form) {
                    return $form->forTemplate();
                },
                'default' => function () use (&$controller) {
                    return $controller->redirectBack();
                }
            ));
            
            if ($controller->getRequest()->isAjax()) {
                $controller->getRequest()->addHeader('X-Pjax', 'CurrentForm');
            }
            
            return $responseNegotiator->respond($controller->getRequest());
        }
        
        if (!empty($list)) {
            $message = "Added " . count($return) . " contacts to mailing list '{$list->Title}'";
        } else {
            $message = _t("Contacts.NoListSelected", "No list selected");
        }

        $form->sessionMessage(
            $message,
            ValidationResult::TYPE_GOOD
        );
        
        // Changes to the record properties might've excluded the record from
        // a filtered list, so return back to the main view if it can't be found
        $link = $controller->Link();
        $controller->getRequest()->addHeader('X-Pjax', 'Content');
        return $controller->redirect($link);
    }
593552
function submitFoundationForm($data, $form) {
		if(isset($data['SecurityID'])) {
			unset($data['SecurityID']);
		}
		Session::set('FoundationForm' . $this->ID, $data);
		
		return $this->redirect($this->Link());
	}
956257
public function doArchive($data, $form)
    {
        /** @var Versioned|DataObject $record */
        $record = $this->getRecord();
        if (!$record->canArchive()) {
            return $this->httpError(403);
        }

        // Record name before it's deleted
        $title = $record->Title;
        $record->doArchive();

        $message = _t(
            __CLASS__ . '.Archived',
            'Archived {name} {title}',
            [
                'name' => $record->i18n_singular_name(),
                'title' => Convert::raw2xml($title)
            ]
        );
        $this->setFormMessage($form, $message);

        //when an item is deleted, redirect to the parent controller
        $controller = $this->getToplevelController();
        $controller->getRequest()->addHeader('X-Pjax', 'Content'); // Force a content refresh

        return $controller->redirect($this->getBackLink(), 302); //redirect back to admin section
    }
255341
public function saveStep(FormInterface $form)
    {
        $answers = $this->getUserConfiguration()->getAnswers();
        $data = $form->getData();
        $answersData = $form->get('answers')->getData();

        if (is_null($answersData)) {
            $answersData = array();
        } else if (!is_array($answersData)) {
            $answersData = array($answersData);
        }

        $answers[$this->getCurrentQuestion()] = array_merge($answersData, $data);
        $this->getUserConfiguration()->setAnswers($answers);
        $this->updateSessionConfiguration();

        return $this;
    }
450911
public function onFakeSubmit(&$form, &$data) {
        if ($this->useMultiRowForm) {
            //Check if the insert button was pressed and act upon that
            if ($this->hasNew() && isset($data['insert_button']) && $data['insert_button']) {
                    // Add a row
                    $model          = $this->getModel();
                    $mname          = $model->getName();
                    $data[$mname][] = $model->loadNew();
            }
        }
    }
360211
public function setForm($form)
    {
        // Associate Fields with Form:
        
        $this->honeypot->setForm($form);
        $this->timestamp->setForm($form);
        
        // Call Parent Method:
        
        return parent::setForm($form);
    }
475704
public function instance_form_save(\stdClass $datanew) {
        $elementname = $this->get_form_element_name();
        if (!property_exists($datanew, $elementname)) {
            return;
        }
        $value = $datanew->$elementname;
        $this->data->set($this->datafield(), $value);
        $this->data->set('value', $value);
        $this->save();
    }
817971
public function doSaveAndQuit($data, $form)
    {
        $this->save($data, $form);
        $controller = $this->getToplevelController();
        $controller->getResponse()->addHeader("X-Pjax", "Content");
        $controller->redirect($this->getBackLink());
    }
1047367
public function doNext($data, $form)
    {
        $this->getToplevelController()->getResponse()->addHeader('X-Pjax', 'Content');
        $link = $this->getEditLink($this->getNextRecordID());
        return $this->redirect($link);
    }
1172401
private function renderForm($form, $data = [])
    {
        // Check for tag name
        if ($form->tagName != 'form') {
            return $this;
        }

        // Set form values
        FormHelper::setValues($this->getHTMLHandler(), $form, $data['values']);

        return $this;
    }
425087
public function filterSucceeded(Form $form)
	{
		if ($this->snippets_set) {
			return;
		}

		$values = $form->getValues();

		if ($this->getPresenter()->isAjax()) {
			if (isset($form['group_action']['submit']) && $form['group_action']['submit']->isSubmittedBy()) {
				return;
			}
		}

		/**
		 * Per page
		 */
		$this->saveSessionData('_grid_per_page', $values->per_page);
		$this->per_page = $values->per_page;

		/**
		 * Inline edit
		 */
		if (isset($form['inline_edit']) && isset($form['inline_edit']['submit']) && isset($form['inline_edit']['cancel'])) {
			$edit = $form['inline_edit'];

			if ($edit['submit']->isSubmittedBy() || $edit['cancel']->isSubmittedBy()) {
				$id = $form->getHttpData(Form::DATA_LINE, 'inline_edit[_id]');
				$primary_where_column = $form->getHttpData(
					Form::DATA_LINE,
					'inline_edit[_primary_where_column]'
				);

				if ($edit['submit']->isSubmittedBy() && !$edit->getErrors()) {
					$this->inlineEdit->onSubmit($id, $values->inline_edit);
					$this->getPresenter()->payload->_datagrid_inline_edited = $id;
					$this->getPresenter()->payload->_datagrid_name = $this->getName();
				} else {
					$this->getPresenter()->payload->_datagrid_inline_edit_cancel = $id;
					$this->getPresenter()->payload->_datagrid_name = $this->getName();
				}

				if ($edit['submit']->isSubmittedBy() && !empty($this->inlineEdit->onCustomRedraw)) {
					$this->inlineEdit->onCustomRedraw();
				} else {
					$this->redrawItem($id, $primary_where_column);
					$this->redrawControl('summary');
				}

				return;
			}
		}

		/**
		 * Inline add
		 */
		if (isset($form['inline_add']) && isset($form['inline_add']['submit']) && isset($form['inline_add']['cancel'])) {
			$add = $form['inline_add'];

			if ($add['submit']->isSubmittedBy() || $add['cancel']->isSubmittedBy()) {
				if ($add['submit']->isSubmittedBy() && !$add->getErrors()) {
					$this->inlineAdd->onSubmit($values->inline_add);

					if ($this->getPresenter()->isAjax()) {
						$this->getPresenter()->payload->_datagrid_inline_added = true;
					}
				}

				return;
			}
		}

		/**
		 * Filter itself
		 */
		$values = $values['filter'];

		foreach ($values as $key => $value) {
			/**
			 * Session stuff
			 */
			if ($this->remember_state && $this->getSessionData($key) != $value) {
				/**
				 * Has been filter changed?
				 */
				$this->page = 1;
				$this->saveSessionData('_grid_page', 1);
			}

			$this->saveSessionData($key, $value);

			/**
			 * Other stuff
			 */
			$this->filter[$key] = $value;
		}

		if (!empty($values)) {
			$this->saveSessionData('_grid_has_filtered', 1);
		}

		if ($this->getPresenter()->isAjax()) {
			$this->getPresenter()->payload->_datagrid_sort = [];

			foreach ($this->columns as $key => $column) {
				if ($column->isSortable()) {
					$this->getPresenter()->payload->_datagrid_sort[$key] = $this->link('sort!', [
						'sort' => $column->getSortNext(),
					]);
				}
			}
		}

		$this->reload();
	}
878683
protected function saveFormIntoRecord($data, $form)
    {
        $list = $this->gridField->getList();

        // Check object matches the correct classname
        if (isset($data['ClassName']) && $data['ClassName'] != $this->record->ClassName) {
            $newClassName = $data['ClassName'];
            // The records originally saved attribute was overwritten by $form->saveInto($record) before.
            // This is necessary for newClassInstance() to work as expected, and trigger change detection
            // on the ClassName attribute
            $this->record->setClassName($this->record->ClassName);
            // Replace $record with a new instance
            $this->record = $this->record->newClassInstance($newClassName);
        }

        // Save form and any extra saved data into this dataobject
        $form->saveInto($this->record);
        $this->record->write();
        $this->extend('onAfterSave', $this->record);

        $extraData = $this->getExtraSavedData($this->record, $list);
        $list->add($this->record, $extraData);

        return $this->record;
    }
148305
public function restore($data, $form)
    {
        if (!isset($data['ID']) || !is_numeric($data['ID'])) {
            return new HTTPResponse("Please pass an ID in the form content", 400);
        }

        $id = (int)$data['ID'];
        /** @var SiteTree $restoredPage */
        $restoredPage = Versioned::get_latest_version(SiteTree::class, $id);
        if (!$restoredPage) {
            return new HTTPResponse("SiteTree #$id not found", 400);
        }

        $restoredPage = $restoredPage->doRestoreToStage();

        $this->getResponse()->addHeader(
            'X-Status',
            rawurlencode(_t(
                __CLASS__ . '.RESTORED',
                "Restored '{title}' successfully",
                array('title' => $restoredPage->Title)
            ))
        );

        return $this->getResponseNegotiator()->respond($this->getRequest());
    }
1114594
public function doUpdatePayment($data, $form)
    {
        $session = $this
            ->getRequest()
            ->getSession();

        $session->set(
            "Checkout.PaymentMethodID",
            $data["PaymentMethodID"]
        );        
        
        return $this->redirectBack();        
    }
1317694
protected function persistData(Form $form)
    {
        parent::persistData($form);

        $positionData = $form->get('tabs')->get('position_tab')->get('position')->getNormData();

        if ($positionData) {
            $positionData = json_decode($positionData);
            /** @var MenuItem $data */
            $data = $form->getData();

            $entityManager = $this->getDoctrine()->getEntityManager();
            /** @var NestedTreeRepository $menuItemRepo */
            $menuItemRepo = $this->getDoctrine()->getRepository($this->getEntityName());

            $positionData->parent = intval($positionData->parent) ? ($positionData->parent) : 0;

            $data->setParent(null);
            if (intval($positionData->parent) > 0) {
                $data->setParent($entityManager->getReference($this->getEntityName(), $positionData->parent));
            }

            $menuItemRepo->persistAsFirstChild($data);
            if ($positionData->position) {
                $menuItemRepo->moveDown($data, $positionData->position);
            }

            $entityManager->flush();
        }
    }
335709
public function results($data, $form, $request)
    {
        // Check parameters for terms, pagination, and if we should follow suggestions
        $keywords = empty($data['Search']) ? '' : $data['Search'];
        $start = isset($data['start']) ? $data['start'] : 0;
        $suggestions = isset($data['suggestions'])
            ? $data['suggestions']
            : $this->config()->get('search_follow_suggestions');

        $results = CwpSearchEngine::create()
            ->search(
                $keywords,
                $this->config()->get('classes_to_search'),
                Injector::inst()->get(CwpSearchEngine::class . '.search_index'),
                $this->config()->get('results_per_page'),
                $start,
                $suggestions
            );

        // Customise content with these results
        $properties = [
            'MetaTitle' => _t(__CLASS__ . '.MetaTitle', 'Search {keywords}', ['keywords' => $keywords]),
            'NoSearchResults' => _t(__CLASS__ . '.NoResult', 'Sorry, your search query did not return any results.'),
            'EmptySearch' => _t(__CLASS__ . '.EmptySearch', 'Search field empty, please enter your search query.'),
            'PdfLink' => '',
            'Title' => _t('SilverStripe\\CMS\\Search\\SearchForm.SearchResults', 'Search Results'),
        ];
        $this->owner->extend('updateSearchResults', $results, $properties);

        // Customise page
        /** @var ViewableData_Customised $response */
        $response = $this->owner->customise($properties);
        if ($results) {
            $response = $response
                ->customise($results)
                ->customise(['Results' => $results->getResults()]);
        }

        // Render
        $templates = $this->getResultsTemplate($request);
        return $response->renderWith($templates);
    }