从extraFields()的url中获取属性的方法是这样的
organizations/6/location?expands=address,city (i have 10 attribute)
但我如何才能从extraFields()中一次性获得所有这些信息呢?
类似这样的组织6location?expands=true或全部。
这个轮廓仪
public function actionIndex($id) {
$locations= Location::findAll($id);
return new ArrayDataProvider([
'allModels' => $locations,
'pagination' => false,
]);
这是我的模型代码
public function fields() {
return [
'id',
'display',
];
}
public function extraFields() {
return [
'address',
'city',
'state',
'country',
'zipcode',
'country_code',
'phone_number',
];
}
我真的不明白你的问题,但我认为你想这样做。
organizations6location?expands=true&address=myadresse&city=mycity......。
你能给我们一些代码来帮助你吗?
你的URL有一个错别字,应该是
expand=address,city
不 expandS=address,city
请看 https:/www.yiiframework.comdocguide2.0enrest-resources#overriding-extra-fields