function doSubmit(array $raw_data, Form $form) { $controller = $form->getController(); $data = Convert::raw2sql($raw_data); $submission = new Distributor(); $form->saveInto($submission); $submission->DistributorPageID = $controller->ID; $submission->write(); return $controller->redirect($controller->Link()); }
/** * Performs the actual action of adding the object to the ChangeSet, once the ChangeSet ID is known * * @param DataObject $object The object to add to the ChangeSet * @param int $campaignID The ID of the ChangeSet to add $object to * @return SS_HTTPResponse * @throws SS_HTTPResponse_Exception */ public function addToCampaign($object, $campaignID) { /** @var ChangeSet $changeSet */ $changeSet = ChangeSet::get()->byID($campaignID); if (!$changeSet) { $this->editForm->httpError(404, _t('AddToCampaign.ErrorNotFound', 'That {Type} couldn\'t be found', '', ['Type' => 'Campaign'])); return null; } if (!$changeSet->canEdit()) { $this->editForm->httpError(403, _t('AddToCampaign.ErrorCampaignPermissionDenied', 'It seems you don\'t have the necessary permissions to add {ObjectTitle} to {CampaignTitle}', '', ['ObjectTitle' => $object->Title, 'CampaignTitle' => $changeSet->Title])); return null; } $changeSet->addObject($object); if (Director::is_ajax()) { $response = new SS_HTTPResponse(_t('AddToCampaign.Success', 'Successfully added {ObjectTitle} to {CampaignTitle}', '', ['ObjectTitle' => $object->Title, 'CampaignTitle' => $changeSet->Title]), 200); $response->addHeader('Content-Type', 'text/plain; charset=utf-8'); return $response; } else { return $this->editForm->getController()->redirectBack(); } }
public function push($data, Form $form) { $toNode = $data['TargetNode']; if ($toNode) { $node = DataList::create('RemoteSyncroNode')->byID($toNode); if ($node) { $status = $this->syncrotronService->pushChangeset($this->record, $node); if (is_array($status)) { $form->sessionMessage($status[1], $status[0] ? 'good' : 'bad'); } } } $controller = $form->getController()->getTopLevelController(); $controller->getRequest()->addHeader('X-Pjax', 'Content'); return $controller->redirect($form->getController()->Link(), 302); }