G
G
Good Samaritan2018-06-11 10:04:56
Yii
Good Samaritan, 2018-06-11 10:04:56

I write the code according to the lessons, why the error?

The actual code

public $name;
  public $email;
  public $text;

  public function attributeLabels() {
    return[
      'name'=>"Имя",
      'email'=>"E-mail",
      'text'=>"Текст сообщения",
    ];
  }
  public function rules() {
    return[
      [['name','email']=>'required'] //ERROR  Illegal offset type
    ];
  }

Answer the question

In order to leave comments, you need to log in

[[+comments_count]] answer(s)
A
Alexey Ukolov, 2018-06-11
@djamali

Because you can't use an array as an array key.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question