V
V
Vitaly2017-03-23 14:17:26
Yii
Vitaly, 2017-03-23 14:17:26

From the view, access the class and pull out the attributes?

there is a class User in which there is a method

public function attributeLabels()
    {
        return $this->commonAttributesLabel() + [
            'username'                  => $this->t('', 'Логин'),
            'first_name'                => $this->t('', 'Имя'),
            'last_name'                 => $this->t('', 'Фамилия'),
            'second_name'               => $this->t('', 'Отчество'),
             ];
    }

How can I get a Name from the view?
Edit:
I have
object(stdClass)[593]
  public 'user' => 
    object(stdClass)[594]
      public 'type' => string 'class' (length=5)
      public 'methodTitle' => string 'modelTitle' (length=10)
      public 'class' => string '\gm\models\users\tables\Users' (length=30)
      public 'fields' => 
        object(stdClass)[595]
          public 'username' => string 'attribute' (length=9)
          public 'first_name' => string 'attribute' (length=9)
          public 'last_name' => string 'attribute' (length=9)
          public 'second_name' => string 'attribute' (length=9)

and I need to display in the field
$user['first_name'] = Name;

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Fedorov, 2017-03-23
@kat-vetal

using the getAttributeLabel() method , for example:
$model->getAttributeLabel('username');

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question