0

To get attribute from extraFields() url is like

 organizations/6/location?expands=address,city (i have 10 attribute)

But how can i get all these at once from extraFields()

something like this organizations/6/location?expands=true or all

This contoller

public function actionIndex($id) {
   $locations= Location::findAll($id);

    return new ArrayDataProvider([
        'allModels' => $locations,

        'pagination' => false,
    ]);

And this is my Model code

public function fields() {
    return [
        'id',
        'display',
    ];
}

public function extraFields() {
    return [
        'address',
        'city',
        'state',
        'country',
        'zipcode',
        'country_code',
        'phone_number',
    ];
}
Bell Carson
  • 127
  • 9

2 Answers2

0

I dont really understand your question, but i think you want to do that :

organizations/6/location?expands=true&address=myadresse&city=mycity ....

Can you give us some code to help you ?

Jonathan Delean
  • 1,011
  • 1
  • 8
  • 25
0

You have a typo in the URL, it should be

expand=address,city not expandS=address,city

See https://www.yiiframework.com/doc/guide/2.0/en/rest-resources#overriding-extra-fields

leealex
  • 1,473
  • 1
  • 17
  • 24