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


PHP ActiveRecord::getAttributeLabel方法代码示例

本文整理汇总了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);
 }
开发者ID:dlds,项目名称:yii2-giixer,代码行数:14,代码来源:GxActiveRecord.php

示例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;
 }
开发者ID:sjoorm,项目名称:yii2-components,代码行数:20,代码来源:Misc.php

示例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;
    }
开发者ID:nisnaker,项目名称:yii2-template,代码行数:19,代码来源:Html.php

示例4: getAttributeLabel

 /**
  * Gets an attribute label
  *
  * @param string $attribute
  *
  * @return string
  */
 public function getAttributeLabel($attribute)
 {
     return parent::getAttributeLabel($attribute);
 }
开发者ID:nox-it,项目名称:yii2-nox-mvc,代码行数:11,代码来源:ActiveRecord.php

示例5: getAttributeLabel

 /**
  * @inheritdoc
  */
 public function getAttributeLabel($attribute)
 {
     if (isset($this->attributeLabels[$attribute])) {
         return Yii::t($this->messageCategory, $this->attributeLabels[$attribute]);
     }
     return parent::getAttributeLabel($attribute);
 }
开发者ID:alesar-code,项目名称:yii2-base,代码行数:10,代码来源:ActiveRecord.php

示例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;
 }
开发者ID:tqsq2005,项目名称:dotplant2,代码行数:30,代码来源:Helper.php


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