mirror of
https://github.com/silverstripe/silverstripe-reports
synced 2024-10-22 11:05:53 +02:00
Merge pull request #770 from chillu/pulls/cmsform
Using new CMSForm class to allow for validation errors in CMS
This commit is contained in:
commit
0bd257c8fc
@ -396,7 +396,7 @@ JS
|
|||||||
|
|
||||||
public function AddForm() {
|
public function AddForm() {
|
||||||
$folder = singleton('Folder');
|
$folder = singleton('Folder');
|
||||||
$form = new Form(
|
$form = CMSForm::create(
|
||||||
$this,
|
$this,
|
||||||
'AddForm',
|
'AddForm',
|
||||||
new FieldList(
|
new FieldList(
|
||||||
@ -408,7 +408,8 @@ JS
|
|||||||
->addExtraClass('ss-ui-action-constructive')->setAttribute('data-icon', 'accept')
|
->addExtraClass('ss-ui-action-constructive')->setAttribute('data-icon', 'accept')
|
||||||
->setTitle(_t('AssetAdmin.ActionAdd', 'Add folder'))
|
->setTitle(_t('AssetAdmin.ActionAdd', 'Add folder'))
|
||||||
)
|
)
|
||||||
);
|
)->setHTMLID('Form_AddForm');
|
||||||
|
$form->setResponseNegotiator($this->getResponseNegotiator());
|
||||||
$form->setTemplate($this->getTemplatesWithSuffix('_EditForm'));
|
$form->setTemplate($this->getTemplatesWithSuffix('_EditForm'));
|
||||||
// TODO Can't merge $FormAttributes in template at the moment
|
// TODO Can't merge $FormAttributes in template at the moment
|
||||||
$form->addExtraClass('add-form cms-add-form cms-edit-form cms-panel-padded center ' . $this->BaseCSSClasses());
|
$form->addExtraClass('add-form cms-add-form cms-edit-form cms-panel-padded center ' . $this->BaseCSSClasses());
|
||||||
|
@ -76,7 +76,7 @@ class CMSFileAddController extends LeftAndMain {
|
|||||||
asort($exts);
|
asort($exts);
|
||||||
$uploadField->Extensions = implode(', ', $exts);
|
$uploadField->Extensions = implode(', ', $exts);
|
||||||
|
|
||||||
$form = new Form(
|
$form = CMSForm::create(
|
||||||
$this,
|
$this,
|
||||||
'getEditForm',
|
'getEditForm',
|
||||||
new FieldList(
|
new FieldList(
|
||||||
@ -84,7 +84,8 @@ class CMSFileAddController extends LeftAndMain {
|
|||||||
new HiddenField('ID')
|
new HiddenField('ID')
|
||||||
),
|
),
|
||||||
new FieldList()
|
new FieldList()
|
||||||
);
|
)->setHTMLID('Form_getEditForm');
|
||||||
|
$form->setResponseNegotiator($this->getResponseNegotiator());
|
||||||
$form->addExtraClass('center cms-edit-form ' . $this->BaseCSSClasses());
|
$form->addExtraClass('center cms-edit-form ' . $this->BaseCSSClasses());
|
||||||
// Don't use AssetAdmin_EditForm, as it assumes a different panel structure
|
// Don't use AssetAdmin_EditForm, as it assumes a different panel structure
|
||||||
$form->setTemplate($this->getTemplatesWithSuffix('_EditForm'));
|
$form->setTemplate($this->getTemplatesWithSuffix('_EditForm'));
|
||||||
|
@ -663,7 +663,10 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
|||||||
$validator = new RequiredFields();
|
$validator = new RequiredFields();
|
||||||
}
|
}
|
||||||
|
|
||||||
$form = new Form($this, "EditForm", $fields, $actions, $validator);
|
$form = CMSForm::create(
|
||||||
|
$this, "EditForm", $fields, $actions, $validator
|
||||||
|
)->setHTMLID('Form_EditForm');
|
||||||
|
$form->setResponseNegotiator($this->getResponseNegotiator());
|
||||||
$form->loadDataFrom($record);
|
$form->loadDataFrom($record);
|
||||||
$form->disableDefaultAction();
|
$form->disableDefaultAction();
|
||||||
$form->addExtraClass('cms-edit-form');
|
$form->addExtraClass('cms-edit-form');
|
||||||
@ -686,9 +689,11 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
|||||||
$this->extend('updateEditForm', $form);
|
$this->extend('updateEditForm', $form);
|
||||||
return $form;
|
return $form;
|
||||||
} else if($id) {
|
} else if($id) {
|
||||||
return new Form($this, "EditForm", new FieldList(
|
$form = CMSForm::create( $this, "EditForm", new FieldList(
|
||||||
new LabelField('PageDoesntExistLabel',_t('CMSMain.PAGENOTEXISTS',"This page doesn't exist"))), new FieldList()
|
new LabelField('PageDoesntExistLabel',_t('CMSMain.PAGENOTEXISTS',"This page doesn't exist"))), new FieldList()
|
||||||
);
|
)->setHTMLID('Form_EditForm');
|
||||||
|
$form->setResponseNegotiator($this->getResponseNegotiator());
|
||||||
|
return $form;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -788,13 +793,14 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
|||||||
}
|
}
|
||||||
));
|
));
|
||||||
|
|
||||||
$listview = new Form(
|
$listview = CMSForm::create(
|
||||||
$this,
|
$this,
|
||||||
'ListViewForm',
|
'ListViewForm',
|
||||||
new FieldList($gridField),
|
new FieldList($gridField),
|
||||||
new FieldList()
|
new FieldList()
|
||||||
);
|
)->setHTMLID('Form_ListViewForm');
|
||||||
$listview->setAttribute('data-pjax-fragment', 'ListViewForm');
|
$listview->setAttribute('data-pjax-fragment', 'ListViewForm');
|
||||||
|
$listview->setResponseNegotiator($this->getResponseNegotiator());
|
||||||
|
|
||||||
$this->extend('updateListView', $listview);
|
$this->extend('updateListView', $listview);
|
||||||
|
|
||||||
|
@ -106,7 +106,10 @@ class CMSPageAddController extends CMSPageEditController {
|
|||||||
|
|
||||||
$this->extend('updatePageOptions', $fields);
|
$this->extend('updatePageOptions', $fields);
|
||||||
|
|
||||||
$form = new Form($this, "AddForm", $fields, $actions);
|
$form = CMSForm::create(
|
||||||
|
$this, "AddForm", $fields, $actions
|
||||||
|
)->setHTMLID('Form_AddForm');
|
||||||
|
$form->setResponseNegotiator($this->getResponseNegotiator());
|
||||||
$form->addExtraClass('cms-add-form stacked cms-content center cms-edit-form ' . $this->BaseCSSClasses());
|
$form->addExtraClass('cms-add-form stacked cms-content center cms-edit-form ' . $this->BaseCSSClasses());
|
||||||
$form->setTemplate($this->getTemplatesWithSuffix('_EditForm'));
|
$form->setTemplate($this->getTemplatesWithSuffix('_EditForm'));
|
||||||
|
|
||||||
|
@ -251,13 +251,13 @@ class CMSPageHistoryController extends CMSMain {
|
|||||||
// Use <button> to allow full jQuery UI styling
|
// Use <button> to allow full jQuery UI styling
|
||||||
foreach($actions->dataFields() as $action) $action->setUseButtonTag(true);
|
foreach($actions->dataFields() as $action) $action->setUseButtonTag(true);
|
||||||
|
|
||||||
$form = new Form(
|
$form = CMSForm::create(
|
||||||
$this,
|
$this,
|
||||||
'VersionsForm',
|
'VersionsForm',
|
||||||
$fields,
|
$fields,
|
||||||
$actions
|
$actions
|
||||||
);
|
)->setHTMLID('Form_VersionsForm');
|
||||||
|
$form->setResponseNegotiator($this->getResponseNegotiator());
|
||||||
$form->loadDataFrom($this->request->requestVars());
|
$form->loadDataFrom($this->request->requestVars());
|
||||||
$hiddenID->setValue($id);
|
$hiddenID->setValue($id);
|
||||||
$form->unsetValidator();
|
$form->unsetValidator();
|
||||||
|
@ -37,7 +37,10 @@ class CMSSettingsController extends LeftAndMain {
|
|||||||
$navField->setAllowHTML(true);
|
$navField->setAllowHTML(true);
|
||||||
|
|
||||||
$actions = $siteConfig->getCMSActions();
|
$actions = $siteConfig->getCMSActions();
|
||||||
$form = new Form($this, 'EditForm', $fields, $actions);
|
$form = CMSForm::create(
|
||||||
|
$this, 'EditForm', $fields, $actions
|
||||||
|
)->setHTMLID('Form_EditForm');
|
||||||
|
$form->setResponseNegotiator($this->getResponseNegotiator());
|
||||||
$form->addExtraClass('root-form');
|
$form->addExtraClass('root-form');
|
||||||
$form->addExtraClass('cms-edit-form cms-panel-padded center');
|
$form->addExtraClass('cms-edit-form cms-panel-padded center');
|
||||||
// don't add data-pjax-fragment=CurrentForm, its added in the content template instead
|
// don't add data-pjax-fragment=CurrentForm, its added in the content template instead
|
||||||
|
@ -171,7 +171,10 @@ class ReportAdmin extends LeftAndMain implements PermissionProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$actions = new FieldList();
|
$actions = new FieldList();
|
||||||
$form = new Form($this, "EditForm", $fields, $actions);
|
$form = CMSForm::create(
|
||||||
|
$this, "EditForm", $fields, $actions
|
||||||
|
)->setHTMLID('Form_EditForm');
|
||||||
|
$form->setResponseNegotiator($this->getResponseNegotiator());
|
||||||
$form->addExtraClass('cms-edit-form cms-panel-padded center ' . $this->BaseCSSClasses());
|
$form->addExtraClass('cms-edit-form cms-panel-padded center ' . $this->BaseCSSClasses());
|
||||||
$form->loadDataFrom($this->request->getVars());
|
$form->loadDataFrom($this->request->getVars());
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user