src/base/Model.php
public function mergeAttributeLabels($labels)
    {
        if (!isset(static::$mergedLabels[static::class])) {
            $default = $this->defaultAttributeLabels();
            foreach ($this->attributes() as $k) {
                $label = $labels[$k] ?: $default[$k];
                if (!$label) {
                    if (preg_match('/(.+)_[a-z]+$/', $k, $m)) {
                        if (isset($labels[$m[1]])) {
                            $label = $labels[$m[1]];
                        }
                    }
                }
                if (!$label) {
                    $toTranslate = preg_replace(['/_id$/', '/_label$/', '/_ids$/', '/_like$/'], [' ID', '', ' IDs', ''], $k);
                    $toTranslate = preg_replace('/_/', ' ', $toTranslate);
                    $label = Yii::t(static::$i18nDictionary, ucfirst($toTranslate));
                }
                $labels[$k] = $label;
            }
            static::$mergedLabels[static::class] = $labels;
        }

        return static::$mergedLabels[static::class];
    }
public function mergeAttributeLabels($labels)
    {
        if (!isset(static::$mergedLabels[static::class])) {
            $default = $this->defaultAttributeLabels();
            foreach ($this->attributes() as $k) {
                $label = $labels[$k] ?: $default[$k];
                if (!$label) {
                    if (preg_match('/(.+)_[a-z]+$/', $k, $m)) {
                        if (isset($labels[$m[1]])) {
                            $label = $labels[$m[1]];
                        }
                    }
                }
                if (!$label) {
                    $toTranslate = preg_replace(['/_id$/', '/_label$/', '/_ids$/', '/_like$/'], [' ID', '', ' IDs', ''], $k);
                    $toTranslate = preg_replace('/_/', ' ', $toTranslate);
                    $label = Yii::t(static::$i18nDictionary, ucfirst($toTranslate));
                }
                $labels[$k] = $label;
            }
            static::$mergedLabels[static::class] = $labels;
        }

        return static::$mergedLabels[static::class];
    }
public function mergeAttributeLabels ( $ labels ) { if ( ! isset ( static :: $ mergedLabels [ static :: class ] ) ) { $ default = $ this -> defaultAttributeLabels ( ) ; foreach ( $ this -> attributes ( ) as $ k ) { $ label = $ labels [ $ k ] ? : $ default [ $ k ] ; if ( ! $ label ) { if ( preg_match ( '/(.+)_[a-z]+$/' , $ k , $ m ) ) { if ( isset ( $ labels [ $ m [ 1 ] ] ) ) { $ label = $ labels [ $ m [ 1 ] ] ; } } } if ( ! $ label ) { $ toTranslate = preg_replace ( [ '/_id$/' , '/_label$/' , '/_ids$/' , '/_like$/' ] , [ ' ID' , '' , ' IDs' , '' ] , $ k ) ; $ toTranslate = preg_replace ( '/_/' , ' ' , $ toTranslate ) ; $ label = Yii :: t ( static :: $ i18nDictionary , ucfirst ( $ toTranslate ) ) ; } $ labels [ $ k ] = $ label ; } static :: $ mergedLabels [ static :: class ] = $ labels ; } return static :: $ mergedLabels [ static :: class ] ; }
Merge Attribute labels for Model.
Merge Attribute labels for Model .