B
B
bizzonaru2016-11-14 11:44:05
Yii
bizzonaru, 2016-11-14 11:44:05

How to properly integrate 3rd party widgets and Yii2 restfull api?

There is, for example, a set of kartik-v widgets. They accept data in json in their format, for example, a choice, a separate field with a previously selected value. There is a standard option in Yii for working with restfull, which returns json in its "format". How can you, without making a crutch on both sides, most conveniently tie it all together without much labor?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Maxim Fedorov, 2016-11-14
@qonand

JSON he and Africa JSON, he has one format everywhere. There may be a different structure of the answer - but the format is always the same. Nothing prevents you from using Yii2 to make such a structure as you need in a certain situation. On the example of the same kartik

public function actionGetData(){
    Yii::$app->response->format = 'json';
    return [
        'output'=> $data,
        'selected'=> '', 
    ]
}

B
bizzonaru, 2016-11-14
@bizzonaru

Yes, I agree that you can change the structure, but in this case you need to customize the restfull yii2 functionality by overriding the actionIndex - prepareDataProvider methods

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question