public function EditForm() { $form = parent::EditForm(); $form->Actions()->removeByName('Delete'); $array = unserialize(Session::get("StoreAdminLatestSearch")); if (is_array($array)) { if (count($array) && count($array) > 1) { foreach ($array as $key => $id) { if ($id == $this->currentRecord->ID) { if (isset($array[$key + 1]) && $array[$key + 1]) { $nextRecordID = $array[$key + 1]; $nextRecordURL = 'admin/' . StoreAdmin::$url_segment . '/' . $this->currentRecord->ClassName . '/' . $nextRecordID . '/edit'; $form->Actions()->push(new FormAction("goNext", "Next Record")); $form->Fields()->push(new HiddenField("nextRecordURL", null, $nextRecordURL)); } if (isset($array[$key - 1]) && $array[$key - 1]) { $prevRecordID = $array[$key - 1]; $nextRecordURL = 'admin/' . StoreAdmin::$url_segment . '/' . $this->currentRecord->ClassName . '/' . $prevRecordID . '/edit'; $form->Actions()->insertFirst(new FormAction("goPrev", "Previous Record")); $form->Fields()->push(new HiddenField("prevRecordURL", null, $nextRecordURL)); } } } } } return $form; }
public function EditForm() { $form = parent::EditForm(); if ($this->parentController->modelClass == 'PermissionRole') { $permissionField = $form->Fields()->dataFieldByName('Codes'); if ($permissionField) { $permissionField->setHiddenPermissions(SecurityAdmin::$hidden_permissions); } } return $form; }
function doCreate($data, $form, $request) { if (isset($data['TemplateID']) && $data['TemplateID']) { $template = DataObject::get_by_id('Subsite_Template', $data['TemplateID']); } else { $template = null; } // Create subsite from existing template switch ($data['Type']) { case 'template': if ($template) { $subsite = $template->duplicate(); } else { $subsite = new Subsite_Template(); $subsite->write(); } break; case 'subsite': default: if ($template) { $subsite = $template->createInstance($data['Title']); } else { $subsite = new Subsite(); $subsite->Title = $data['Title']; $subsite->write(); } break; } $form->dataFieldByName('Domains')->setExtraData(array("SubsiteID" => $subsite->ID)); $form->saveInto($subsite); $subsite->write(); if (Director::is_ajax()) { $recordController = new ModelAdmin_RecordController($this, $request, $subsite->ID); return new SS_HTTPResponse($recordController->EditForm()->forAjaxTemplate(), 200, sprintf(_t('ModelAdmin.LOADEDFOREDITING', "Loaded '%s' for editing."), $subsite->Title)); } else { Director::redirect(Controller::join_links($this->Link(), $subsitess->ID, 'edit')); } }
/** * Returns a form for editing the attached model */ public function EditForm() { $form = parent::EditForm(); $oldActions = $form->Actions(); //in order of appearance //$form->unsetActionByName("action_doDelete"); - USEFUL TO KEEP $form->unsetActionByName("action_unpublish"); $form->unsetActionByName("action_delete"); $form->unsetActionByName("action_save"); $form->unsetActionByName("action_publish"); //$form->unsetActionByName("action_doSave"); - USEFUL TO KEEP $actions = $form->Actions(); $actions->push(new FormAction("doGoto", "go to page")); $form->setActions($actions); return $form; }
/** * Returns a form for editing the attached model * *@return Form **/ public function EditForm() { $form = parent::EditForm(); if ($this->currentRecord instanceof SiteTree) { $oldActions = $form->Actions(); //in order of appearance //$form->unsetActionByName("action_doDelete"); - USEFUL TO KEEP $form->unsetActionByName("action_unpublish"); $form->unsetActionByName("action_delete"); $form->unsetActionByName("action_save"); $form->unsetActionByName("action_publish"); //$form->unsetActionByName("action_doSave"); - USEFUL TO KEEP $actions = $form->Actions(); $actions->push(new FormAction("doGoto", "go to page")); $form->setActions($actions); } if ($this->parentController) { $array = unserialize(Session::get("BusinessListingMananger" . $this->parentController->getModelClass())); if (is_array($array)) { if (count($array) && count($array) > 1) { foreach ($array as $key => $id) { if ($id == $this->currentRecord->ID) { if (isset($array[$key + 1]) && $array[$key + 1]) { $nextRecordID = $array[$key + 1]; $nextRecordURL = $this->parentController->Link(Controller::join_links($nextRecordID, "edit")); $form->Actions()->push(new FormAction("goNext", "Next Record")); $form->Fields()->push(new HiddenField("nextRecordURL", null, $nextRecordURL)); } if (isset($array[$key - 1]) && $array[$key - 1]) { $prevRecordID = $array[$key - 1]; $nextRecordURL = $this->parentController->Link(Controller::join_links($prevRecordID, "edit")); $form->Actions()->insertFirst(new FormAction("goPrev", "Previous Record")); $form->Fields()->push(new HiddenField("prevRecordURL", null, $nextRecordURL)); } } } } } } return $form; }
/** * @return Form */ public function EditForm() { $form = parent::EditForm(); $form->Actions()->removeByName('action_goBack'); return $form; }
public function EditForm() { $form = parent::EditForm(); if(is_subclass_of($this->currentRecord->class,"SiteTree")) { $live_link = Controller::join_links($this->currentRecord->Link(),'?stage=Live'); $stage_link = Controller::join_links($this->currentRecord->Link(),'?stage=Stage'); $form->setActions($this->currentRecord->getCMSActions()); $form->Fields()->insertFirst(new LiteralField('back','<div class="modelpagenav clr"><button id="list_view">« '._t('RemodelAdmin.BACKTOLIST','Back to list view').'</button></div>')); $form->Fields()->insertFirst(new LiteralField('view','<div class="publishpreviews clr">'._t('RemodelAdmin.VIEW','View Page').': <a target="_blank" href="'.$live_link.'">'._t('RemodelAdmin.VIEWLIVE','Live Site').'</a> <a target="_blank" href="'.$stage_link.'">'._t('RemodelAdmin.VIEWDRAFT','Draft Site').'</a></div></div>')); if($parent = $this->parentController->parentController->getParentPage()) { $form->Fields()->push(new HiddenField('ParentID','', $parent->ID)); } elseif($parent_class = $this->parentController->stat('parent_page_type')) { $form->Fields()->push(new SimpleTreeDropdownField('ParentID', _t('RemodelAdmin.PARENTPAGE','Parent page'), $parent_class)); } } return $form; }
/** * Create the form for editing a model. * * @see ModelAdmin_RecordController::EditForm() * @return Form */ public function EditForm() { $form = parent::EditForm(); if ($this->currentRecord instanceof Product || is_subclass_of($this->currentRecord->class, 'Product')) { //Add another option to ParentType field for when products are not part of the site tree $fields = $form->Fields(); $parentTypeField = $fields->fieldByName('Root.Behaviour.ParentType'); if ($parentTypeField && $parentTypeField->exists() && $parentTypeField instanceof OptionsetField) { $source = $parentTypeField->getSource(); $source['exempt'] = _t('ShopAdmin.NOT_PART_OF_SITE_TREE', "Not part of the site tree"); $parentTypeField->setSource($source); $parentTypeField->setValue($this->currentRecord->getParentType()); } } if (is_subclass_of($this->currentRecord->class, "SiteTree")) { $form->setActions($this->currentRecord->getCMSActions()); $live_link = Controller::join_links($this->currentRecord->Link(), '?stage=Live'); $stage_link = Controller::join_links($this->currentRecord->Link(), '?stage=Stage'); $form->Fields()->insertFirst(new LiteralField('view', '<div class="publishpreviews clr">' . _t('ShopAdmin.VIEW', 'View Page') . ': <a target="_blank" href="' . $live_link . '">' . _t('ShopAdmin.VIEWLIVE', 'Live Site') . '</a> <a target="_blank" href="' . $stage_link . '">' . _t('ShopAdmin.VIEWDRAFT', 'Draft Site') . '</a></div></div>')); $form->Fields()->insertFirst(new LiteralField('back', '<div class="modelpagenav clr"><button id="list_view">« ' . _t('ShopAdmin.BACKTOLIST', 'Back to list view') . '</button>')); } else { $form->Fields()->insertFirst(new LiteralField('back', '<div class="modelpagenav clr"><button id="list_view">« ' . _t('ShopAdmin.BACKTOLIST', 'Back to list view') . '</button></div>')); } return $form; }