Handle the ticket form registration

@param array $data
@param SummaryForm $form
@return \SS_HTTPResponse
@throws \ValidationException
3059
public function makePayment(array $data, SummaryForm $form)
    {
        // If the summary is changed and email receivers are set
        if (isset($data['Summary']) && is_array($data['Summary'])) {
            foreach ($data['Summary'] as $attendeeID => $fields) {
                $attendee = $form->reservation->Attendees()->find('ID', $attendeeID);
                foreach ($fields as $field => $value) {
                    $attendee->setField($field, $value);
                }
                $attendee->write();
            }
        }

        $form->saveInto($form->reservation);
        // If comments are added
        //if (isset($data['Comments'])) {
        //    $form->reservation->Comments = $data['Comments'];
        //}

        // Hook trough where optional extra field data can be saved on the reservation
        $this->extend('updateReservationBeforePayment', $form->reservation, $data, $form);

        // Check if there is a payment to process otherwise continue with manual processing
        $gateway = $form->reservation->Total > 0
            ? $data['Gateway']
            : 'Manual';

        $form->reservation->changeState('PENDING');
        $form->reservation->Gateway = $gateway;
        $form->reservation->write();

        $paymentProcessor = PaymentProcessor::create($this->reservation);
        $paymentProcessor
            ->createPayment($gateway)
            ->setSuccessUrl($this->getController()->Link($this->nextStep))
            ->setFailureUrl($this->getController()->Link())
            ->write();

        $paymentProcessor->setGateWayData(array(
            'transactionId' => $this->reservation->ReservationCode
        ));

        $response = $paymentProcessor->createServiceFactory();
        $this->extend('beforeNextStep', $data, $form, $response);
        return $response->redirectOrRespond();
    }
2272
public function doUpdate($data, $form)
    {
        try {
            foreach ($this->Items() as $item) {
                foreach ($data as $key => $value) {
                    $sliced_key = explode("_", $key);
                    if ($sliced_key[0] == "Quantity") {
                        if (isset($item) && ($item->Key == $sliced_key[1])) {
                            if ($value > 0) {
                                ShoppingCartFactory::create()->updateItem(
                                    $item,
                                    $value
                                );
                            } else {
                                $item->delete();
                            }

                            $form->sessionMessage(
                                _t("ShoppingCart.UpdatedShoppingCart", "Shopping cart updated"),
                                ValidationResult::TYPE_GOOD
                            );
                        }
                    }
                }
            }
            ShoppingCartFactory::create()->save();
        } catch (ValidationException $e) {
            $form->sessionMessage(
                $e->getMessage()
            );
        } catch (Exception $e) {
            $form->sessionMessage(
                $e->getMessage()
            );
        }
        
        return $this->redirectBack();
    }
593552
function submitFoundationForm($data, $form) {
		if(isset($data['SecurityID'])) {
			unset($data['SecurityID']);
		}
		Session::set('FoundationForm' . $this->ID, $data);
		
		return $this->redirect($this->Link());
	}
174900
public function doRegister($data, $form)
    {
        $r = new EventRegistration();
        $form->saveInto($r);
        $r->write();

        return "Thanks. We've received your registration.";
    }
74250
public function addtocampaign($data, $form)
    {
        $id = $data['ID'];
        $record = \Page::get()->byID($id);

        $handler = AddToCampaignHandler::create($this, $record);
        $results = $handler->addToCampaign($record, $data);
        if (is_null($results)) {
            return null;
        }

        if ($this->getSchemaRequested()) {
            // Send extra "message" data with schema response
            $extraData = ['message' => $results];
            $schemaId = Controller::join_links($this->Link('schema/AddToCampaignForm'), $id);
            return $this->getSchemaResponse($schemaId, $form, null, $extraData);
        }

        return $results;
    }
1222463
public function doFrontEndAction(array $data, Form $form, HTTPRequest $request)
    {
        if (!$obj = $this->getContextObject()) {
            throw new Exception(
                _t(
                    'FrontEndWorkflowController.FRONTENDACTION_CONTEXT_EXCEPTION',
                    'Context Object Not Found'
                )
            );
        }

        if (!$this->getCurrentTransition()->canExecute($this->contextObj->getWorkflowInstance())) {
            throw new Exception(
                _t(
                    'FrontEndWorkflowController.FRONTENDACTION_TRANSITION_EXCEPTION',
                    'You do not have permission to execute this action'
                )
            );
        }

        //Only Save data when Transition is 'Active'
        if ($this->getCurrentTransition()->Type == 'Active') {
            //Hand off to WorkflowAction to perform Save
            $svc    = singleton(WorkflowService::class);
            $active = $svc->getWorkflowFor($obj);

            $active->doFrontEndAction($data, $form, $request);
        }

        //run execute on WorkflowInstance instance
        $action = $this->contextObj->getWorkflowInstance()->currentAction();
        $action->BaseAction()->execute($this->contextObj->getWorkflowInstance());

        //get valid transitions
        $transitions = $action->getValidTransitions();

        //tell instance to execute transition if it's in the permitted list
        if ($transitions->find('ID', $this->transitionID)) {
            $this->contextObj->getWorkflowInstance()->performTransition($this->getCurrentTransition());
        }
    }
1347033
public function validate(Form $form) : void
    {
        if ($this->presenter->isAjax())
        {
            foreach ($form->getErrors() as $error)
            {
                $this->presenter->notificationAjax('Chyba', $error, 'error');
            }
        }
    }
1114594
public function doUpdatePayment($data, $form)
    {
        $session = $this
            ->getRequest()
            ->getSession();

        $session->set(
            "Checkout.PaymentMethodID",
            $data["PaymentMethodID"]
        );        
        
        return $this->redirectBack();        
    }
561639
public function updateEditForm($form) {
        $classNameField = $form->Fields()->dataFieldByName('ClassName');
        if ($classNameField) {
            $className = $classNameField->Value();
            if ($className === 'Site') 
            {
            	$form->Fields()->removeByName(array(SilverStripeNavigator::class));
                $form->removeExtraClass('cms-previewable');
            }
        }
    }
200215
public function delete($data, $form) {
		$className = $this->stat('tree_class');

		$record = DataObject::get_by_id($className, Convert::raw2sql($data['ID']));
		if($record && !$record->canDelete()) return Security::permissionFailure();
		if(!$record || !$record->ID) $this->httpError(404, "Bad record ID #" . (int)$data['ID']);
		$type = $record->ClassName;
		$record->delete();

		Session::set("FormInfo.Form_EditForm.formError.message", "Deleted $type");
		Session::set("FormInfo.Form_EditForm.formError.type", 'bad');

		$this->response->addHeader('X-Status', rawurlencode(_t('LeftAndMain.DELETED', 'Deleted.')));
		return $this->getResponseNegotiator()->respond(
			$this->request,
			array('currentform' => array($this, 'EmptyForm'))
		);
	}
1280880
public function success(Form $form) : void
    {
        if ($this->presenter->isAjax())
        {
            $values = $form->getValues();

            try
            {
                $this->pageManager->saveName($this->activePage, $values->name);
                $this->pageManager->saveParentPage($this->activeLang, $this->activePage, $values->parentPageId);

                $this->presenter->notificationAjax(
                    'Nastavení stránky',
                    'Hlavní nastavení stránky bylo úspěšně uloženo.',
                    'success',
                    FALSE
                );

                $this->onSave();
            }
            catch (DatabaseException $exception)
            {
                $this->presenter->notificationAjax(
                    'Chyba',
                    $exception->getMessage(),
                    'error'
                );
            }
            catch (\Exception $exception)
            {
                throw $exception;
            }
        }
    }
1123819
public function submitted(Form $form)
	{
		if (!isset($form['group_action']['submit']) || !$form['group_action']['submit']->isSubmittedBy()) {
			return;
		}

		$values = $form->getValues();
		$values = $values['group_action'];

		if ($values->group_action === 0 || $values->group_action === null) {
			return;
		}

		/**
		 * @todo Define items IDs
		 */
		$http_ids = $form->getHttpData(Form::DATA_LINE | Form::DATA_KEYS, strtolower($this->datagrid->getName()) . '_group_action_item[]');
		$ids = array_keys($http_ids);

		$id = $values->group_action;
		$this->group_actions[$id]->onSelect($ids, isset($values->{$id}) ? $values->{$id} : null);

		$form['group_action']['group_action']->setValue(null);
	}
289992
public function handle_form_submission(local\forms\editstep &$mform, \stdClass $data) {
        $this->set_title($data->title);
        $this->set_content($data->content);
        $this->set_targettype($data->targettype);

        $this->set_targetvalue($this->get_target()->get_value_from_form($data));

        foreach (self::get_config_keys() as $key) {
            if (!$this->get_target()->is_setting_forced($key)) {
                if (isset($data->$key)) {
                    $value = $data->$key;
                } else {
                    $value = configuration::TOURDEFAULT;
                }
                if ($value === configuration::TOURDEFAULT) {
                    $this->set_config($key, null);
                } else {
                    $this->set_config($key, $value);
                }
            }
        }

        $this->persist();

        return $this;
    }
698497
protected function handleForm(FormInterface $form, $successMessage, $itemToPersist = null)
    {
        if ($form->isValid()) {
            $documentManager = $this->get('object_manager');

            if ($itemToPersist) {
                $documentManager->persist($itemToPersist);
            }

            $documentManager->flush();

            $this->get('session')->getFlashBag()->add('success', $successMessage);

            return true;
        }

        return false;
    }
9989
static function getDataValidator($data, $form = null) {
        $v = static::getVendor();
        if ($v) {
            $v .= '::';
        }
        $filters = (array)\Config::get($v . 'models/' . static::getEntity() . '/filters');
        $rules   = (array)\Config::get($v . 'models/' . static::getEntity() . '/rules');
        $rules = Arr::only($rules, array_keys($data));
//        dump($data);
//        dd($rules);





        //        dump($rules);
        //        \Debugbar::addMessage($rules);
        \Debugbar::addMessage($data);
        $labels   = static::getEntityLabels();
        $messages = static::getEntityValidationMessage();
        \Debugbar::addMessage($labels);
        \Debugbar::addMessage($messages);
        foreach ($filters as $field => $field_filters) {
            //            $field_filters = ['trim'] + $field_filters;
            foreach ($field_filters as $field_filter) {
                $elements  = $form ? $form->getElementsByName($field) : [];
                $options   = [];
                $options[] = Arr::get($data, $field);
                if ($field_filter instanceof \Closure) {
                    $options[] = $data;
                    $options[] = $elements;
                }
                if (isset($data[$field])) {
                    $data[$field] = call_user_func_array($field_filter, $options);
                }
            }
        }
        $class     = static::getClassDataValidator();
        $validator = new $class;

        return $validator->setData((array)$data)->setRules((array)$rules)->setLabels((array)$labels)->setMessages((array)$messages);
    }
624981
public function doSave($data, $form)
    {
        $className = $this->gridField->list->dataClass;
        $singleton = singleton($className);

        $formsData = array();
        $ids = array();
        $done = 0;

        //unescape and sort form data per record ID
        foreach ($data as $fieldName => $value) {
            if ($fieldInfo = $this->unEscapeFieldName($fieldName)) {
                if (!isset($formsData[$fieldInfo['id']])) {
                    $formsData[$fieldInfo['id']] = array();
                }

                $formsData[$fieldInfo['id']][$fieldInfo['name']] = $value;
            }
        }

        //process each record's form data and save
        foreach ($formsData as $recordID => $recordData) {
            $record = DataObject::get_by_id($className, $recordID);
            $recordForm = Form::create(
                $this,
                'RecordForm',
                $record->getCMSFields(),
                FieldList::create()
            );

            $recordForm->loadDataFrom($recordData);
            $recordForm->saveInto($record);
            $id = $record->write();

            array_push($ids, $record->ID);

            if ($id) {
                ++$done;
            }
        }

        //compose form message
        $messageModelClass = (($done > 1) ? $singleton->i18n_plural_name() : $singleton->i18n_singular_name());
        $message = _t(
            'GRIDFIELD_BULKMANAGER_EDIT_HANDLER.SAVE_RESULT_TEXT',
            '{count} {class} saved successfully.',
            array(
                'count' => $done,
                'class' => $messageModelClass,
            )
        );
        $form->sessionMessage($message, 'good');

        //return back to form
        return Controller::curr()->redirect($this->Link('?records[]=' . implode('&records[]=', $ids)));
        //return Controller::curr()->redirect($form->Backlink); //returns to gridField
    }
1209512
public function doNew($data, $form)
    {
        return $this->redirect(Controller::join_links($this->gridField->Link('item'), 'new'));
    }