mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-10-22 06:05:56 +00:00
Fix campaign form validation errors
This commit is contained in:
parent
c9477ee141
commit
1273059b4c
@ -11,6 +11,7 @@ use SilverStripe\Control\HTTPRequest;
|
|||||||
use SilverStripe\Control\HTTPResponse;
|
use SilverStripe\Control\HTTPResponse;
|
||||||
use SilverStripe\Forms\Form;
|
use SilverStripe\Forms\Form;
|
||||||
use SilverStripe\ORM\FieldType\DBHTMLText;
|
use SilverStripe\ORM\FieldType\DBHTMLText;
|
||||||
|
use SilverStripe\ORM\ValidationResult;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @package cms
|
* @package cms
|
||||||
@ -58,7 +59,7 @@ class CMSPageEditController extends CMSMain
|
|||||||
$record = \Page::get()->byID($id);
|
$record = \Page::get()->byID($id);
|
||||||
|
|
||||||
$handler = AddToCampaignHandler::create($this, $record);
|
$handler = AddToCampaignHandler::create($this, $record);
|
||||||
$results = $handler->addToCampaign($record, $data['Campaign']);
|
$results = $handler->addToCampaign($record, $data);
|
||||||
if (is_null($results)) {
|
if (is_null($results)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -97,7 +98,7 @@ class CMSPageEditController extends CMSMain
|
|||||||
|
|
||||||
if (!$record) {
|
if (!$record) {
|
||||||
$this->httpError(404, _t(
|
$this->httpError(404, _t(
|
||||||
'SilverStripe\\AssetAdmin\\Controller\\AssetAdmin.ErrorNotFound',
|
__CLASS__ . '.ErrorNotFound',
|
||||||
'That {Type} couldn\'t be found',
|
'That {Type} couldn\'t be found',
|
||||||
'',
|
'',
|
||||||
['Type' => Page::singleton()->i18n_singular_name()]
|
['Type' => Page::singleton()->i18n_singular_name()]
|
||||||
@ -106,7 +107,7 @@ class CMSPageEditController extends CMSMain
|
|||||||
}
|
}
|
||||||
if (!$record->canView()) {
|
if (!$record->canView()) {
|
||||||
$this->httpError(403, _t(
|
$this->httpError(403, _t(
|
||||||
'SilverStripe\\AssetAdmin\\Controller\\AssetAdmin.ErrorItemPermissionDenied',
|
__CLASS__.'.ErrorItemPermissionDenied',
|
||||||
'It seems you don\'t have the necessary permissions to add {ObjectTitle} to a campaign',
|
'It seems you don\'t have the necessary permissions to add {ObjectTitle} to a campaign',
|
||||||
'',
|
'',
|
||||||
['ObjectTitle' => Page::singleton()->i18n_singular_name()]
|
['ObjectTitle' => Page::singleton()->i18n_singular_name()]
|
||||||
@ -115,6 +116,13 @@ class CMSPageEditController extends CMSMain
|
|||||||
}
|
}
|
||||||
|
|
||||||
$handler = AddToCampaignHandler::create($this, $record);
|
$handler = AddToCampaignHandler::create($this, $record);
|
||||||
return $handler->Form($record);
|
$form = $handler->Form($record);
|
||||||
|
|
||||||
|
$form->setValidationResponseCallback(function (ValidationResult $errors) use ($form, $id) {
|
||||||
|
$schemaId = Controller::join_links($this->Link('schema/AddToCampaignForm'), $id);
|
||||||
|
return $this->getSchemaResponse($schemaId, $form, $errors);
|
||||||
|
});
|
||||||
|
|
||||||
|
return $form;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user