Source of file MultisitesCMSPageAddController.php
Size: 1,019 Bytes - Last Modified: 2021-12-23T10:20:19+00:00
/var/www/docs.ssmods.com/process/src/code/admin/MultisitesCMSPageAddController.php
12345678910111213141516171819202122232425262728293031323334353637383940 | <?php /** * An extension to the default page add interface which doesn't allow pages to * be created on the root. * * @package silverstripe-multisites */ class MultisitesCMSPageAddController extends CMSPageAddController { private static $allowed_actions = array( 'AddForm' ); public static $url_priority = 43; public function AddForm() { $form = parent::AddForm(); $fields = $form->Fields(); $fields->push(new HiddenField('Parent', null, true)); // Enforce a parent mode of "child" to correctly read the "allowed children". $fields->dataFieldByName('ParentModeField')->setValue('child'); $fields->insertAfter($parent = new TreeDropdownField( 'ParentID', '', 'SiteTree', 'ID', 'TreeTitle' ), 'ParentModeField'); $parentID = $this->request->getVar('ParentID'); $parentID = $parentID ? $parentID : Multisites::inst()->getCurrentSiteId(); $parent->setForm($form); $parent->setValue((int)$parentID); $form->setValidator(new RequiredFields('ParentID')); return $form; } } |