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


PHP FormResponse::update_dom_id方法代码示例

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


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

示例1: saveInto

 public function saveInto($record)
 {
     $data = $this->form->getRecord();
     // if the record was written for the first time (has an arbitrary "new"-ID),
     // update the imagefield to enable uploading
     if ($record->ID && $data && substr($data->ID, 0, 3) == 'new') {
         FormResponse::update_dom_id($this->id(), $this->Field($record->ID));
     }
 }
开发者ID:ramziammar,项目名称:websites,代码行数:9,代码来源:ImageField.php

示例2: ajax_refresh

	/**
	 * Returns the content of the TableListField as a piece of FormResponse javascript
	 * @deprecated Please use the standard URL through Link() which gives you the FieldHolder as an HTML fragment.
	 */
	function ajax_refresh() {
		// compute sourceItems here instead of Items() to ensure that
		// pagination and filters are respected on template accessors
		//$this->sourceItems();

		$response = $this->renderWith($this->template);
		FormResponse::update_dom_id($this->id(), $response, 1);
		FormResponse::set_non_ajax_content($response);
		return FormResponse::respond();
	}
开发者ID:neopba,项目名称:silverstripe-book,代码行数:14,代码来源:TableListField.php

示例3: addtogroup

	/**
	 * Add existing member to group rather than creating a new member
	 */
	function addtogroup() {
		$data = $_REQUEST;
		unset($data['ID']);
		$ctfID = isset($data['ctf']) ? $data['ctf']['ID'] : null;

		if(!is_numeric($ctfID)) {
			FormResponse::status_messsage(_t('MemberTableField.ADDINGFIELD', 'Adding failed'), 'bad');
		}

		$className = Object::getCustomClass($this->stat('data_class'));
		$record = new $className();

		$record->update($data);
		
		$valid = $record->validate();

		if($valid->valid()) {
			$record->write();
			$record->Groups()->add($ctfID);

			$this->sourceItems();

			// TODO add javascript to highlight added row (problem: might not show up due to sorting/filtering)
			FormResponse::update_dom_id($this->id(), $this->renderWith($this->template), true);
			FormResponse::status_message(_t('MemberTableField.ADDEDTOGROUP','Added member to group'), 'good');
		
		} else {
			FormResponse::status_message(Convert::raw2xml("I couldn't add that user to this group:\n\n" . $valid->starredlist()), 'bad');
		}

		return FormResponse::respond();
	}
开发者ID:neopba,项目名称:silverstripe-book,代码行数:35,代码来源:MemberTableField.php

示例4: addtogroup

 /**
  * Add existing member to group rather than creating a new member
  */
 function addtogroup()
 {
     // Protect against CSRF on destructive action
     $token = $this->getForm()->getSecurityToken();
     if (!$token->checkRequest($this->controller->getRequest())) {
         return $this->httpError(400);
     }
     $data = $_REQUEST;
     $groupID = isset($data['ctf']['ID']) ? $data['ctf']['ID'] : null;
     if (!is_numeric($groupID)) {
         FormResponse::status_messsage(_t('MemberTableField.ADDINGFIELD', 'Adding failed'), 'bad');
         return;
     }
     // Get existing record either by ID or unique identifier.
     $identifierField = Member::get_unique_identifier_field();
     $className = self::$data_class;
     $record = null;
     if (isset($data[$identifierField])) {
         $record = DataObject::get_one($className, sprintf('"%s" = \'%s\'', $identifierField, $data[$identifierField]));
         if ($record && !$record->canEdit()) {
             return $this->httpError('401');
         }
     }
     // Fall back to creating a new record
     if (!$record) {
         $record = new $className();
     }
     // Update an existing record, or populate a new one.
     // If values on an existing (autocompleted) record have been changed,
     // they will overwrite current data. We need to unset 'ID'
     // record as it points to the group rather than the member record, and would
     // cause the member to be written to a potentially existing record.
     unset($data['ID']);
     $record->update($data);
     // Validate record, mainly password restrictions.
     // Note: Doesn't use Member_Validator
     $valid = $record->validate();
     if ($valid->valid()) {
         $record->write();
         $record->Groups()->add($groupID);
         $this->sourceItems();
         // TODO add javascript to highlight added row (problem: might not show up due to sorting/filtering)
         FormResponse::update_dom_id($this->id(), $this->renderWith($this->template), true);
         FormResponse::status_message(_t('MemberTableField.ADDEDTOGROUP', 'Added member to group'), 'good');
     } else {
         $message = sprintf(_t('MemberTableField.ERRORADDINGUSER', 'There was an error adding the user to the group: %s'), Convert::raw2xml($valid->starredList()));
         FormResponse::status_message($message, 'bad');
     }
     return FormResponse::respond();
 }
开发者ID:comperio,项目名称:silverstripe-cms,代码行数:53,代码来源:MemberTableField.php

示例5: saveInto

 /** 
  * Saves the Dataobjects contained in the field
  */
 function saveInto(DataObject $record)
 {
     // CMS sometimes tries to set the value to one.
     if (is_array($this->value)) {
         $newFields = array();
         // Sort into proper array
         $value = ArrayLib::invert($this->value);
         $dataObjects = $this->sortData($value, $record->ID);
         // New fields are nested in their own sub-array, and need to be sorted separately
         if (isset($dataObjects['new']) && $dataObjects['new']) {
             $newFields = $this->sortData($dataObjects['new'], $record->ID);
         }
         // Update existing fields
         // @todo Should this be in an else{} statement?
         $savedObjIds = $this->saveData($dataObjects, $this->editExisting);
         // Save newly added record
         if ($savedObjIds || $newFields) {
             $savedObjIds = $this->saveData($newFields, false);
         }
         // Optionally save the newly created records into a relationship
         // on $record. This assumes the name of this formfield instance
         // is set to a relationship name on $record.
         if ($this->relationAutoSetting) {
             $relationName = $this->Name();
             if ($record->has_many($relationName) || $record->many_many($relationName)) {
                 if ($savedObjIds) {
                     foreach ($savedObjIds as $id => $status) {
                         $record->{$relationName}()->add($id);
                     }
                 }
             }
         }
         // Update the internal source items cache
         $this->value = null;
         $items = $this->sourceItems();
         FormResponse::update_dom_id($this->id(), $this->FieldHolder());
     }
 }
开发者ID:SustainableCoastlines,项目名称:loveyourwater,代码行数:41,代码来源:TableField.php

示例6: saveComplexTableField

 /**
  * Use the URL-Parameter "action_saveComplexTableField"
  * to provide a clue to the main controller if the main form has to be rendered,
  * even if there is no action relevant for the main controller (to provide the instance of ComplexTableField
  * which in turn saves the record.
  *
  * @see {Form::ReferencedField}).
  */
 function saveComplexTableField()
 {
     if (isset($_REQUEST['ctf']['childID']) && is_numeric($_REQUEST['ctf']['childID'])) {
         $childObject = DataObject::get_by_id($this->sourceClass, $_REQUEST['ctf']['childID']);
     } else {
         $childObject = new $this->sourceClass();
         $this->fields->removeByName('ID');
     }
     $this->saveInto($childObject);
     $funcName = $this->controller->itemWriteMethod;
     if (!$funcName) {
         $funcName = "write";
     }
     $childObject->{$funcName}();
     // if ajax-call in an iframe, update window
     if (Director::is_ajax()) {
         // Newly saved objects need their ID reflected in the reloaded form to avoid double saving
         $form = $this->controller->DetailForm($childObject->ID);
         $form->loadDataFrom($childObject);
         FormResponse::update_dom_id($form->FormName(), $form->formHtmlContent(), true, 'update');
         return FormResponse::respond();
     } else {
         Director::redirectBack();
     }
 }
开发者ID:ramziammar,项目名称:websites,代码行数:33,代码来源:ComplexTableField.php

示例7: saveInto

	/** 
	 * Saves the Dataobjects contained in the field
	 */
	function saveInto(DataObject $record) {
		// CMS sometimes tries to set the value to one.
		if(is_array($this->value)){
			
			// Sort into proper array
			$this->value = ArrayLib::invert($this->value);
			$dataObjects = $this->sortData($this->value, $record->ID);
			if(isset($dataObjects['new']) && $dataObjects['new']) {
				$newFields = $this->sortData($dataObjects['new'], $record->ID);
			}

			$savedObj = $this->saveData($dataObjects, $this->editExisting);
			if($savedObj && isset($newFields)) {
				$savedObj = $this->saveData($newFields,false);
			} else if(isset($newFields)) {
				$savedObj = $this->saveData($newFields,false);
			}
			$items = $this->sourceItems();
			FormResponse::update_dom_id($this->id(), $this->FieldHolder());
		}
	}
开发者ID:neopba,项目名称:silverstripe-book,代码行数:24,代码来源:TableField.php


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