yii\db\ActiveRecord::attributes PHP Method

attributes() public method

The default implementation will return all column names of the table associated with this AR class.
public attributes ( ) : array
return array list of attribute names.
    public function attributes()
    {
        return array_keys(static::getTableSchema()->columns);
    }

Usage Example

Beispiel #1
0
 /**
  * List of model fields displayed in form
  *
  * ```php
  *  return [
  *      'id' => [
  *          'class' => Input::className(),
  *      ],
  *      'username' => [
  *          'class' => Input::className(),
  *      ],
  *      'status' => [
  *          'class' => Select::className(),
  *          'items' => [User::STATUS_ACTIVE => 'Active', User::STATUS_DELETED => 'Deleted'],
  *      ],
  *  ];
  * ```
  *
  * Default is all model attributes with class = Input
  *
  * @return array
  */
 public function fields()
 {
     $fields = [];
     foreach ($this->model->attributes() as $attribute) {
         $fields[$attribute] = ['class' => Input::className()];
     }
     return $fields;
 }
All Usage Examples Of yii\db\ActiveRecord::attributes