本文整理汇总了PHP中BaseElementModel::getFieldColumnPrefix方法的典型用法代码示例。如果您正苦于以下问题:PHP BaseElementModel::getFieldColumnPrefix方法的具体用法?PHP BaseElementModel::getFieldColumnPrefix怎么用?PHP BaseElementModel::getFieldColumnPrefix使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BaseElementModel
的用法示例。
在下文中一共展示了BaseElementModel::getFieldColumnPrefix方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: saveContent
/**
* Saves an element's content.
*
* @param BaseElementModel $element The element whose content we're saving.
* @param bool $validate Whether the element's content should be validated first.
* @param bool $updateOtherLocales Whether any non-translatable fields' values should be copied to the
* element's other locales.
*
* @throws Exception
* @return bool Whether the content was saved successfully. If it wasn't, any validation errors will be saved on the
* element and its content model.
*/
public function saveContent(BaseElementModel $element, $validate = true, $updateOtherLocales = true)
{
if (!$element->id) {
throw new Exception(Craft::t('Cannot save the content of an unsaved element.'));
}
$originalContentTable = $this->contentTable;
$originalFieldColumnPrefix = $this->fieldColumnPrefix;
$originalFieldContext = $this->fieldContext;
$this->contentTable = $element->getContentTable();
$this->fieldColumnPrefix = $element->getFieldColumnPrefix();
$this->fieldContext = $element->getFieldContext();
$content = $element->getContent();
if (!$validate || $this->validateContent($element)) {
$this->_saveContentRow($content);
$fieldLayout = $element->getFieldLayout();
if ($fieldLayout) {
if ($updateOtherLocales && craft()->isLocalized()) {
$this->_duplicateNonTranslatableFieldValues($element, $content, $fieldLayout, $nonTranslatableFields, $otherContentModels);
}
$this->_updateSearchIndexes($element, $content, $fieldLayout, $nonTranslatableFields, $otherContentModels);
}
$success = true;
} else {
$element->addErrors($content->getErrors());
$success = false;
}
$this->contentTable = $originalContentTable;
$this->fieldColumnPrefix = $originalFieldColumnPrefix;
$this->fieldContext = $originalFieldContext;
return $success;
}