当前位置: 首页>>代码示例>>PHP>>正文


PHP TreeDropdownField::setValue方法代码示例

本文整理汇总了PHP中TreeDropdownField::setValue方法的典型用法代码示例。如果您正苦于以下问题:PHP TreeDropdownField::setValue方法的具体用法?PHP TreeDropdownField::setValue怎么用?PHP TreeDropdownField::setValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TreeDropdownField的用法示例。


在下文中一共展示了TreeDropdownField::setValue方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: setValue

 public function setValue($value)
 {
     if ($value) {
         self::set_last_folder($value);
     }
     parent::setValue($value);
 }
开发者ID:helpfulrobot,项目名称:silverstripe-selectupload,代码行数:7,代码来源:FolderDropdownField.php

示例2: AddForm

 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;
 }
开发者ID:helpfulrobot,项目名称:sheadawson-silverstripe-multisites,代码行数:15,代码来源:MultisitesCMSPageAddController.php

示例3: AddForm

 /**
  * @return Form
  */
 public function AddForm()
 {
     $pageTypes = array();
     foreach ($this->PageTypes() as $type) {
         $html = sprintf('<span class="page-icon class-%s"></span><strong class="title">%s</strong><span class="description">%s</span>', $type->getField('ClassName'), $type->getField('AddAction'), $type->getField('Description'));
         $pageTypes[$type->getField('ClassName')] = DBField::create_field('HTMLText', $html);
     }
     // Ensure generic page type shows on top
     if (isset($pageTypes['Page'])) {
         $pageTitle = $pageTypes['Page'];
         $pageTypes = array_merge(array('Page' => $pageTitle), $pageTypes);
     }
     $numericLabelTmpl = '<span class="step-label"><span class="flyout">%d</span><span class="arrow"></span><span class="title">%s</span></span>';
     $topTitle = _t('CMSPageAddController.ParentMode_top', 'Top level');
     $childTitle = _t('CMSPageAddController.ParentMode_child', 'Under another page');
     $fields = new FieldList(new LiteralField('PageModeHeader', sprintf($numericLabelTmpl, 1, _t('CMSMain.ChoosePageParentMode', 'Choose where to create this page'))), $parentModeField = new SelectionGroup("ParentModeField", array(new SelectionGroup_Item("top", null, $topTitle), new SelectionGroup_Item('child', $parentField = new TreeDropdownField("ParentID", "", 'SiteTree', 'ID', 'TreeTitle'), $childTitle))), $typeField = new OptionsetField("PageType", sprintf($numericLabelTmpl, 2, _t('CMSMain.ChoosePageType', 'Choose page type')), $pageTypes, 'Page'), new LiteralField('RestrictedNote', sprintf('<p class="message notice message-restricted">%s</p>', _t('CMSMain.AddPageRestriction', 'Note: Some page types are not allowed for this selection'))));
     $parentField->setSearchFunction(function ($sourceObject, $labelField, $search) {
         return DataObject::get($sourceObject, sprintf("\"MenuTitle\" LIKE '%%%s%%' OR \"Title\" LIKE '%%%s%%'", Convert::raw2sql($search), Convert::raw2sql($search)));
     });
     // TODO Re-enable search once it allows for HTML title display,
     // see http://open.silverstripe.org/ticket/7455
     // $parentField->setShowSearch(true);
     $parentModeField->addExtraClass('parent-mode');
     // CMSMain->currentPageID() automatically sets the homepage,
     // which we need to counteract in the default selection (which should default to root, ID=0)
     if ($parentID = $this->getRequest()->getVar('ParentID')) {
         $parentModeField->setValue('child');
         $parentField->setValue((int) $parentID);
     } else {
         $parentModeField->setValue('top');
     }
     $actions = new FieldList(FormAction::create("doAdd", _t('CMSMain.Create', "Create"))->addExtraClass('ss-ui-action-constructive')->setAttribute('data-icon', 'accept')->setUseButtonTag(true), FormAction::create("doCancel", _t('CMSMain.Cancel', "Cancel"))->addExtraClass('ss-ui-action-destructive ss-ui-action-cancel')->setUseButtonTag(true));
     $this->extend('updatePageOptions', $fields);
     $form = CMSForm::create($this, "AddForm", $fields, $actions)->setHTMLID('Form_AddForm');
     $form->setAttribute('data-hints', $this->SiteTreeHints());
     $form->setAttribute('data-childfilter', $this->Link('childfilter'));
     $form->setResponseNegotiator($this->getResponseNegotiator());
     $form->addExtraClass('cms-add-form stacked cms-content center cms-edit-form ' . $this->BaseCSSClasses());
     $form->setTemplate($this->getTemplatesWithSuffix('_EditForm'));
     return $form;
 }
开发者ID:aaronleslie,项目名称:aaronunix,代码行数:44,代码来源:CMSPageAddController.php

示例4: AddForm

 /**
  * @return Form
  */
 function AddForm()
 {
     $record = $this->currentPage();
     $pageTypes = array();
     foreach ($this->PageTypes() as $type) {
         $html = sprintf('<span class="page-icon class-%s"></span><strong class="title">%s</strong><span class="description">%s</span>', $type->getField('ClassName'), $type->getField('AddAction'), $type->getField('Description'));
         $pageTypes[$type->getField('ClassName')] = $html;
     }
     // Ensure generic page type shows on top
     if (isset($pageTypes['Page'])) {
         $pageTitle = $pageTypes['Page'];
         $pageTypes = array_merge(array('Page' => $pageTitle), $pageTypes);
     }
     $numericLabelTmpl = '<span class="step-label"><span class="flyout">%d</span><span class="arrow"></span><span class="title">%s</span></span>';
     $topTitle = _t('CMSPageAddController.ParentMode_top', 'Top level');
     $childTitle = _t('CMSPageAddController.ParentMode_child', 'Under another page');
     $fields = new FieldList($hintsField = new LiteralField('Hints', sprintf('<span class="hints" data-hints="%s"></span>', $this->SiteTreeHints())), new LiteralField('PageModeHeader', sprintf($numericLabelTmpl, 1, _t('CMSMain.ChoosePageParentMode', 'Choose where to create this page'))), $parentModeField = new SelectionGroup("ParentModeField", array("top//{$topTitle}" => null, "child//{$childTitle}" => $parentField = new TreeDropdownField("ParentID", "", 'SiteTree', 'ID', 'TreeTitle'))), $typeField = new OptionsetField("PageType", sprintf($numericLabelTmpl, 2, _t('CMSMain.ChoosePageType', 'Choose page type')), $pageTypes, 'Page'));
     // TODO Re-enable search once it allows for HTML title display,
     // see http://open.silverstripe.org/ticket/7455
     // $parentField->setShowSearch(true);
     $parentModeField->setValue($this->request->getVar('ParentID') ? 'child' : 'top');
     $parentModeField->addExtraClass('parent-mode');
     // CMSMain->currentPageID() automatically sets the homepage,
     // which we need to counteract in the default selection (which should default to root, ID=0)
     $homepageSegment = RootURLController::get_homepage_link();
     if ($record && $record->URLSegment != $homepageSegment) {
         $parentField->setValue($record->ID);
     }
     $actions = new FieldList(FormAction::create("doAdd", _t('CMSMain.Create', "Create"))->addExtraClass('ss-ui-action-constructive')->setAttribute('data-icon', 'accept')->setUseButtonTag(true));
     $this->extend('updatePageOptions', $fields);
     $form = new Form($this, "AddForm", $fields, $actions);
     $form->addExtraClass('cms-add-form stacked cms-content center cms-edit-form ' . $this->BaseCSSClasses());
     $form->setTemplate($this->getTemplatesWithSuffix('_EditForm'));
     if ($parentID = $this->request->getVar('ParentID')) {
         $form->Fields()->dataFieldByName('ParentID')->setValue((int) $parentID);
     }
     return $form;
 }
开发者ID:nzjoel,项目名称:silverstripe-cms,代码行数:41,代码来源:CMSPageAddController.php

示例5: getListField

 /**
  * @param $folderID The ID of the folder to display.
  * @return FormField
  */
 protected function getListField($folderID)
 {
     // Generate the folder selection field.
     $folderField = new TreeDropdownField('ParentID', _t('HtmlEditorField.FOLDER', 'Folder'), 'Folder');
     $folderField->setValue($folderID);
     // Generate the file list field.
     $config = GridFieldConfig::create();
     $config->addComponent(new GridFieldSortableHeader());
     $config->addComponent(new GridFieldFilterHeader());
     $config->addComponent($columns = new GridFieldDataColumns());
     $columns->setDisplayFields(array('StripThumbnail' => '', 'Name' => 'Name', 'Title' => 'Title'));
     $config->addComponent(new GridFieldPaginator(8));
     // If relation is to be autoset, we need to make sure we only list compatible objects.
     $baseClass = $this->parent->getRelationAutosetClass();
     // Create the data source for the list of files within the current directory.
     $files = DataList::create($baseClass)->filter('ParentID', $folderID);
     $fileField = new GridField('Files', false, $files, $config);
     $fileField->setAttribute('data-selectable', true);
     if ($this->parent->getAllowedMaxFileNumber() !== 1) {
         $fileField->setAttribute('data-multiselect', true);
     }
     $selectComposite = new CompositeField($folderField, $fileField);
     return $selectComposite;
 }
开发者ID:hemant-chakka,项目名称:awss,代码行数:28,代码来源:UploadField.php

示例6: AddForm

	/**
	 * @return Form
	 */
	function AddForm() {
		// If request send from rightclick-submenu, directly add Page
		if(($pageType = $this->request->getVar('Type')) && ($parentID = $this->request->getVar('ParentID'))) {
			$data = array(
				"PageType" => (string)$pageType,
				"ParentID" => $parentID,
				"ParentModeField" => "child"
			);
			$this->doAdd($data, null);
			return;
		}


		$record = $this->currentPage();
		
		$pageTypes = array();
		foreach($this->PageTypes() as $type) {
			$html = sprintf('<span class="icon class-%s"></span><strong class="title">%s</strong><span class="description">%s</span>',
				$type->getField('ClassName'),
				$type->getField('AddAction'),
				$type->getField('Description')
			);
			$pageTypes[$type->getField('ClassName')] = $html;
		}
		// Ensure generic page type shows on top
		if(isset($pageTypes['Page'])) {
			$pageTitle = $pageTypes['Page'];
			$pageTypes = array_merge(array('Page' => $pageTitle), $pageTypes);
		}

		$numericLabelTmpl = '<span class="step-label"><span class="flyout">%d</span><span class="arrow"></span><span class="title">%s</span></span>';

		$topTitle = _t('CMSPageAddController.ParentMode_top', 'Top level');
		$childTitle = _t('CMSPageAddController.ParentMode_child', 'Under another page');

		$fields = new FieldList(
			// new HiddenField("ParentID", false, ($this->parentRecord) ? $this->parentRecord->ID : null),
			// TODO Should be part of the form attribute, but not possible in current form API
			$hintsField = new LiteralField('Hints', sprintf('<span class="hints" data-hints="%s"></span>', $this->SiteTreeHints())),
			new LiteralField('PageModeHeader', sprintf($numericLabelTmpl, 1, _t('CMSMain.ChoosePageParentMode', 'Choose where to create this page'))),
			
			$parentModeField = new SelectionGroup(
				"ParentModeField",
				array(
					"top//$topTitle" => null, //new LiteralField("Dummy", ''),
					"child//$childTitle" => $parentField = new TreeDropdownField(
						"ParentID", 
						"",
						'SiteTree'
					)
				)
			),
			$typeField = new OptionsetField(
				"PageType", 
				sprintf($numericLabelTmpl, 2, _t('CMSMain.ChoosePageType', 'Choose page type')), 
				$pageTypes, 
				'Page'
			)
		);
		$parentField->setShowSearch(true);
		$parentModeField->setValue($this->request->getVar('ParentID') ? 'child' : 'top');
		$parentModeField->addExtraClass('parent-mode');

		// CMSMain->currentPageID() automatically sets the homepage,
		// which we need to counteract in the default selection (which should default to root, ID=0)
		$homepageSegment = RootURLController::get_homepage_link();
		if($record && $record->URLSegment != $homepageSegment) {
			$parentField->setValue($record->ID);	
		}
		
		$actions = new FieldList(
			// $resetAction = new ResetFormAction('doCancel', _t('CMSMain.Cancel', 'Cancel')),
			FormAction::create("doAdd", _t('CMSMain.Create',"Create"))
				->addExtraClass('ss-ui-action-constructive')->setAttribute('data-icon', 'accept')
				->setUseButtonTag(true)
		);
		
		$this->extend('updatePageOptions', $fields);
		
		$form = new Form($this, "AddForm", $fields, $actions);
		$form->addExtraClass('cms-add-form stacked cms-content center cms-edit-form ' . $this->BaseCSSClasses());
		$form->setTemplate($this->getTemplatesWithSuffix('_EditForm'));

		if($parentID = $this->request->getVar('ParentID')) {
			$form->Fields()->dataFieldByName('ParentID')->setValue((int)$parentID);
		}

		return $form;
	}
开发者ID:redema,项目名称:silverstripe-cms,代码行数:92,代码来源:CMSPageAddController.php

示例7: CreatePageForm

 /**
  * Returns the form used to create new pages. If the current form is not set
  * (ie the user is NOT currently editing), then we just return null.
  *
  * @return Form
  */
 public function CreatePageForm()
 {
     $createOptions = array('child' => 'As a child of the selected page', 'sibling' => 'As a sibling of the selected page');
     $pageTree = new TreeDropdownField('CreateContext', _t('WikiPage.CREATE_CONTEXT', 'Select an existing page'), 'WikiPage');
     $pageTree->setValue($this->ID);
     $pageTree->setTreeBaseID($this->data()->getWikiRoot()->ID);
     $fields = FieldList::create(new TextField('NewPageName', _t('WikiPage.NEW_PAGE_NAME', 'New Page Name')), $pageTree, new OptionsetField('CreateType', _t('WikiPage.CREATE_OPTIONS', 'and create the new page '), $createOptions, 'child'));
     $actions = FieldList::create(new FormAction('addpage', _t('WikiPage.ADD_PAGE', 'Create')));
     return new Form($this, 'CreatePageForm', $fields, $actions);
 }
开发者ID:nyeholt,项目名称:silverstripe-simplewiki,代码行数:16,代码来源:WikiPage.php

示例8: getListField

 /**
  * @param $folderID The ID of the folder to display.
  * @return FormField
  */
 protected function getListField($folderID)
 {
     // Generate the folder selection field.
     $folderField = new TreeDropdownField('ParentID', _t('HtmlEditorField.FOLDER', 'Folder'), 'Folder');
     $folderField->setValue($folderID);
     // Generate the file list field.
     $config = GridFieldConfig::create();
     $config->addComponent(new GridFieldSortableHeader());
     $config->addComponent(new GridFieldFilterHeader());
     $config->addComponent(new GridFieldDataColumns());
     $config->addComponent(new GridFieldPaginator(10));
     // If relation is to be autoset, we need to make sure we only list compatible objects.
     $baseClass = null;
     if ($this->parent->relationAutoSetting) {
         $baseClass = $this->parent->getRelationAutosetClass();
     }
     // By default we can attach anything that is a file, or derives from file.
     if (!$baseClass) {
         $baseClass = 'File';
     }
     // Create the data source for the list of files within the current directory.
     $files = DataList::create($baseClass)->filter('ParentID', $folderID);
     $fileField = new GridField('Files', false, $files, $config);
     $fileField->setAttribute('data-selectable', true);
     if ($this->parent->getConfig('allowedMaxFileNumber') > 1) {
         $fileField->setAttribute('data-multiselect', true);
     }
     $selectComposite = new CompositeField($folderField, $fileField);
     return $selectComposite;
 }
开发者ID:prostart,项目名称:cobblestonepath,代码行数:34,代码来源:UploadField.php

示例9: getListField

	/**
	 * @param $folderID The ID of the folder to display.
	 * @return FormField
	 */
	protected function getListField($folderID) {
		// Generate the folder selection field.
		$folderField = new TreeDropdownField('ParentID', _t('HtmlEditorField.FOLDER', 'Folder'), 'Folder');
		$folderField->setValue($folderID);

		// Generate the file list field.
		$config = GridFieldConfig::create();
		$config->addComponent(new GridFieldSortableHeader());
		$config->addComponent(new GridFieldFilterHeader());
		$config->addComponent(new GridFieldDataColumns());
		$config->addComponent(new GridFieldPaginator(10));

		// Create the data source for the list of files within the current directory.
		$files = DataList::create('File')->filter('ParentID', $folderID);

		// If relation is to be autoset, make sure only objects from related class are listed.
		if ($this->parent->relationAutoSetting) {
			if ($relationClass = $this->parent->getRelationAutosetClass()) {
				$files->filter('ClassName', $relationClass);
			}
		}

		$fileField = new GridField('Files', false, $files, $config);
		$fileField->setAttribute('data-selectable', true);
		if($this->parent->getConfig('allowedMaxFileNumber') > 1) $fileField->setAttribute('data-multiselect', true);

		$selectComposite = new CompositeField(
			$folderField,
			$fileField
		);

		return $selectComposite;
	}
开发者ID:redema,项目名称:sapphire,代码行数:37,代码来源:UploadField.php

示例10: AddForm

 /**
  * @return Form
  */
 function AddForm()
 {
     $record = $this->currentPage();
     $pageTypes = array();
     foreach ($this->PageTypes() as $type) {
         $html = sprintf('<span class="icon class-%s"></span><strong class="title">%s</strong><span class="description">%s</span>', $type->getField('ClassName'), $type->getField('AddAction'), $type->getField('Description'));
         $pageTypes[$type->getField('ClassName')] = $html;
     }
     $fields = new FieldSet($hintsField = new LiteralField('Hints', sprintf('<span class="hints" data-hints="%s"></span>', $this->SiteTreeHints())), $parentField = new TreeDropdownField("ParentID", _t('CMSMain.AddFormParentLabel', 'Parent page'), 'SiteTree'), new OptionsetField("PageType", "", $pageTypes, 'Page'));
     $parentField->setValue($record ? $record->ID : null);
     $actions = new FieldSet($createAction = new FormAction("doAdd", _t('CMSMain.Create', "Create")));
     // $resetAction->addExtraClass('ss-ui-action-destructive');
     $createAction->addExtraClass('ss-ui-action-constructive');
     $this->extend('updatePageOptions', $fields);
     $form = new Form($this, "AddForm", $fields, $actions);
     $form->addExtraClass('cms-add-form');
     return $form;
 }
开发者ID:rixrix,项目名称:silverstripe-cms,代码行数:21,代码来源:CMSMain.php

示例11: getListField

 /**
  * @param int $folderID The ID of the folder to display.
  * @return FormField
  */
 protected function getListField($folderID)
 {
     // Generate the folder selection field.
     $folderField = new TreeDropdownField('ParentID', _t('HTMLEditorField.FOLDER', 'Folder'), 'Folder');
     $folderField->setValue($folderID);
     // Generate the file list field.
     $config = GridFieldConfig::create();
     $config->addComponent(new GridFieldSortableHeader());
     $config->addComponent(new GridFieldFilterHeader());
     $config->addComponent($colsComponent = new GridFieldDataColumns());
     $colsComponent->setDisplayFields(array('StripThumbnail' => '', 'Title' => singleton('File')->fieldLabel('Title'), 'Created' => singleton('File')->fieldLabel('Created'), 'Size' => singleton('File')->fieldLabel('Size')));
     $colsComponent->setFieldCasting(array('Created' => 'DBDatetime->Nice'));
     // Set configurable pagination for file list field
     $pageSize = Config::inst()->get(get_class($this), 'page_size');
     $config->addComponent(new GridFieldPaginator($pageSize));
     // If relation is to be autoset, we need to make sure we only list compatible objects.
     $baseClass = $this->parent->getRelationAutosetClass();
     // Create the data source for the list of files within the current directory.
     $files = DataList::create($baseClass)->exclude('ClassName', 'Folder');
     if ($folderID) {
         $files = $files->filter('ParentID', $folderID);
     }
     $fileField = new GridField('Files', false, $files, $config);
     $fileField->setAttribute('data-selectable', true);
     if ($this->parent->getAllowedMaxFileNumber() !== 1) {
         $fileField->setAttribute('data-multiselect', true);
     }
     $selectComposite = new CompositeField($folderField, $fileField);
     return $selectComposite;
 }
开发者ID:jacobbuck,项目名称:silverstripe-framework,代码行数:34,代码来源:UploadField.php


注:本文中的TreeDropdownField::setValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。