本文整理汇总了PHP中yii\db\ActiveRecord::getAttributeLabel方法的典型用法代码示例。如果您正苦于以下问题:PHP ActiveRecord::getAttributeLabel方法的具体用法?PHP ActiveRecord::getAttributeLabel怎么用?PHP ActiveRecord::getAttributeLabel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yii\db\ActiveRecord
的用法示例。
在下文中一共展示了ActiveRecord::getAttributeLabel方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getAttributeLabel
/**
* @inheritdoc
*/
public function getAttributeLabel($attribute)
{
$behavior = $this->getBehavior(self::BN_MUTATION);
if ($behavior && in_array($attribute, $behavior->attrs)) {
$relation = ArrayHelper::getValue($behavior->config, 3, false);
if ($relation) {
$attribute = sprintf('%s.%s', $relation, $attribute);
}
}
return parent::getAttributeLabel($attribute);
}
示例2: attributesToString
/**
* Formats associative array of attributes to string for email body insertion
* @param ActiveRecord $model
* @param boolean $html
* @return string
*/
public static function attributesToString(ActiveRecord $model, $html = true)
{
$result = '';
$delimiter = $html ? "<br/>\n" : "\n";
$attributes = $model instanceof PrintableRecordInterface ? $model->getAttributesToPrint($html) : $model->attributes;
foreach ($attributes as $key => $value) {
if (is_array($value)) {
$value = json_encode($value);
}
$label = $model->getAttributeLabel($key);
$result .= "<strong>{$label}:</strong> {$value} {$delimiter}";
}
return $result;
}
示例3: editor
public static function editor(ActiveRecord $model, $name, $options = [])
{
$label = $model->getAttributeLabel($name);
$value = $model->{$name};
$class = get_class($model);
$class = basename(str_replace('\\', '/', $class));
$low_class = strtolower($class);
$filed_id = $low_class . '-' . $name;
$str = <<<STR
<div class="form-group field-{$filed_id} editor" data-input-name="{$class}[{$name}]">
<label class="control-label" for="{$filed_id}">{$label}</label>
<div class="wrapper">
<textarea id="{$filed_id}" style="width:600px" name="{$class}[{$name}]">{$value}</textarea>
</div>
</div>
<script>KindEditor.create('#{$filed_id}', KEOptions)</script>
STR;
return $str;
}
示例4: getAttributeLabel
/**
* Gets an attribute label
*
* @param string $attribute
*
* @return string
*/
public function getAttributeLabel($attribute)
{
return parent::getAttributeLabel($attribute);
}
示例5: getAttributeLabel
/**
* @inheritdoc
*/
public function getAttributeLabel($attribute)
{
if (isset($this->attributeLabels[$attribute])) {
return Yii::t($this->messageCategory, $this->attributeLabels[$attribute]);
}
return parent::getAttributeLabel($attribute);
}
示例6: getRelationDataByModel
/**
* used with backend/widgets/DataRelationsWidget
* @param ActiveRecord $model
* @param $relationData
* @return array
*/
public static function getRelationDataByModel(ActiveRecord $model, $relationData)
{
$result = [];
foreach ($relationData as $name => $data) {
if ($data['type'] == 'field') {
if (isset($model->attributes[$data['key']])) {
$result[$name] = ['value' => $model->{$data['key']}, 'label' => $model->getAttributeLabel($data['key'])];
}
} elseif ($data['type'] == 'property') {
try {
$result[$name] = ['value' => $model->AbstractModel->{$data['key']}, 'label' => $model->AbstractModel->getAttributeLabel($data['key'])];
} catch (Exception $e) {
Yii::warning('relation data not found: class: ' . $model::className() . '; relation Type' . $data['type'] . '; id ' . $model->id);
}
} elseif ($data['type'] == 'relation') {
try {
$result[$name] = ['value' => $model->{$data['relationName']}->{$data['key']}, 'label' => $model->{$data['relationName']}->getAttributeLabel($data['key'])];
} catch (Exception $e) {
Yii::warning('relation data not found: class: ' . $model::className() . '; relation Type' . $data['type'] . '; id ' . $model->id);
}
}
}
return $result;
}