MINOR Moving CMS-specific customisations to GridFieldPopupForms into form getter, so it also applies when the form has validation errors

This commit is contained in:
Ingo Schommer 2012-03-05 16:59:24 +01:00
parent 9a02f19b66
commit 8a4a6efe29

View File

@ -152,7 +152,7 @@ class GridFieldPopupForm_ItemRequest extends RequestHandler {
*/
public function __construct($gridField, $component, $record, $popupController, $popupFormName) {
$this->gridField = $gridField;
$this->component = $gridField;
$this->component = $component;
$this->record = $record;
$this->popupController = $popupController;
$this->popupFormName = $popupFormName;
@ -167,19 +167,6 @@ class GridFieldPopupForm_ItemRequest extends RequestHandler {
$controller = $this->popupController;
$form = $this->ItemEditForm($this->gridField, $request);
// TODO Coupling with CMS
if($controller instanceof LeftAndMain) {
$form->addExtraClass('cms-edit-form');
$form->setTemplate($controller->getTemplatesWithSuffix('_EditForm'));
$form->addExtraClass('cms-content center ss-tabset ' . $controller->BaseCSSClasses());
if($form->Fields()->hasTabset()) $form->Fields()->findOrMakeTab('Root')->setTemplate('CMSTabSet');
// TODO Link back to controller action (and edited root record) rather than index,
// which requires more URL knowledge than the current link to this field gives us.
// The current root record is held in session only,
// e.g. page/edit/show/6/ vs. page/edit/EditForm/field/MyGridField/....
$form->Backlink = $controller->Link();
}
$return = $this->customise(array(
'Backlink' => $controller->Link(),
'ItemEditForm' => $form,
@ -221,6 +208,20 @@ class GridFieldPopupForm_ItemRequest extends RequestHandler {
)
);
$form->loadDataFrom($this->record);
// TODO Coupling with CMS
if($this->popupController instanceof LeftAndMain) {
$form->addExtraClass('cms-edit-form');
$form->setTemplate($this->popupController->getTemplatesWithSuffix('_EditForm'));
$form->addExtraClass('cms-content center ss-tabset ' . $this->popupController->BaseCSSClasses());
if($form->Fields()->hasTabset()) $form->Fields()->findOrMakeTab('Root')->setTemplate('CMSTabSet');
// TODO Link back to controller action (and edited root record) rather than index,
// which requires more URL knowledge than the current link to this field gives us.
// The current root record is held in session only,
// e.g. page/edit/show/6/ vs. page/edit/EditForm/field/MyGridField/....
$form->Backlink = $this->popupController->Link();
}
return $form;
}