Merge pull request #1297 from patricknelson/issue-586-delete-validation-3.2

FIX for #586 and possible fix for #736 and relates to #2449: Don't perform validation upon deletion, since it isn't necessary.
This commit is contained in:
Damian Mooyman 2015-10-16 17:18:16 +13:00
commit bc669311dd
2 changed files with 143 additions and 124 deletions

View File

@ -593,7 +593,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
/**
* @param int $id
* @param FieldList $fields
* @return Form
* @return CMSForm
*/
public function getEditForm($id = null, $fields = null) {
@ -676,7 +676,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
// if($form->Fields()->hasTabset()) $form->Fields()->findOrMakeTab('Root')->setTemplate('CMSTabSet');
$form->setAttribute('data-pjax-fragment', 'CurrentForm');
// Set validation exemptions for specific actions
$form->setValidationExemptActions(array('restore', 'revert', 'deletefromlive', 'rollback'));
$form->setValidationExemptActions(array('restore', 'revert', 'deletefromlive', 'delete', 'unpublish', 'rollback'));
// Announce the capability so the frontend can decide whether to allow preview or not.
if(in_array('CMSPreviewable', class_implements($record))) {

View File

@ -465,6 +465,25 @@ class CMSMainTest extends FunctionalTest {
$pages->column('Title')
);
}
/**
* Testing retrieval and type of CMS edit form.
*/
public function testGetEditForm() {
// Login is required prior to accessing a CMS form.
$this->loginWithPermission('ADMIN');
// Get a associated with a fixture page.
$page = $this->objFromFixture('Page', 'page1');
$controller = new CMSMain();
$form = $controller->getEditForm($page->ID);
$this->assertInstanceOf("CMSForm", $form);
// Ensure that the form will not "validate" on delete or "unpublish" actions.
$exemptActions = $form->getValidationExemptActions();
$this->assertContains("delete", $exemptActions);
$this->assertContains("unpublish", $exemptActions);
}
}
class CMSMainTest_ClassA extends Page implements TestOnly {