T
T
teodor7teodor72016-06-17 11:38:44
Yii
teodor7teodor7, 2016-06-17 11:38:44

How to organize a POST request for REST yii2?

Created a controller inheriting ActiveController.

class MestypeController extends ActiveController {
public $modelClass = 'app\models\Mestypes';
public function behaviors() {
return [
[
'class' => \yii\filters\ContentNegotiator::className(),
'only' => ['index', 'view', 'create' ],
'formats' => [
'application/json' => \yii\web\Response::FORMAT_JSON,
],
],
];
}...

Postmenos send POST request in response
{
"id": 37,
"status": null,
"name": null,
"short_name": null,
"edit": 37,
"delete": 37
}

Although there is data instead of Null. How to organize?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
teodor7teodor7, 2016-07-28
@teodor7teodor7

Rules() had to be specified in the model

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question