本文整理匯總了PHP中X2Model::getField方法的典型用法代碼示例。如果您正苦於以下問題:PHP X2Model::getField方法的具體用法?PHP X2Model::getField怎麽用?PHP X2Model::getField使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類X2Model
的用法示例。
在下文中一共展示了X2Model::getField方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: renderAttribute
public function renderAttribute($fieldName, $makeLinks = true, $textOnly = true, $encode = true)
{
$field = $this->owner->getField($fieldName);
if (!isset($field)) {
return null;
}
if (!YII_UNIT_TESTING && Yii::app()->params->noSession) {
$webRequestAttributes = array('rating', 'assignment', 'optionalAssignment', 'url', 'text');
if (in_array($field->type, $webRequestAttributes)) {
return $this->render($this->owner->{$fieldName}, $encode);
}
}
$renderByNameFn = 'render' . ucfirst($field->fieldName);
$renderByTypeFn = 'render' . ucfirst($field->type);
// first check for field-specific renderer. Exclude field names that match an existing
// type
if (method_exists($this, $renderByNameFn) && !in_array($field->fieldName, $this->getValidFieldTypes())) {
return $this->{$renderByNameFn}($field, $makeLinks, $textOnly, $encode);
} elseif (method_exists($this, $renderByTypeFn)) {
return $this->{$renderByTypeFn}($field, $makeLinks, $textOnly, $encode);
} else {
return $this->render($this->owner->{$fieldName}, $encode);
}
}