【发布时间】:2015-10-06 09:51:36
【问题描述】:
是否可以将 json 解码数组设置为genemu_jqueryselect2_choice 输入的选项?
我尝试了以下方法:
$search = $this->createFormBuilder()
->add('departure', 'genemu_jqueryselect2_choice', array(
'choices' => $airports,
'label' => 'Departure',
))
->getForm()
;
导致
Warning: Illegal offset type
$airports 是一个 stdClass 对象数组,解码后看起来像这样:
array:1711 [▼
0 => {#1036 ▼
+"lfi": "XXXXXXXX1"
+"icao": "ENEG"
+"iata": null
+"faaCode": null
+"name": " Eggemoen"
+"city": " Eggemoen"
+"countryCode": "FR"
+"latitudeDecimal": "-60.2272220"
+"longitudeDecimal": "10.3058330"
+"utcStdConversion": null
}
1 => {#1037 ▼
+"lfi": "SP80307"
+"icao": "LECO"
+"iata": "LCG"
+"faaCode": null
+"name": "A CORUNA"
+"city": "LA CORUNA"
+"countryCode": "ES"
+"latitudeDecimal": "43.3020611"
+"longitudeDecimal": "-8.3772556"
+"utcStdConversion": "+1"
}
... and so on
【问题讨论】:
标签: json jquery-select2