0
看起來好像有錯誤或文檔是錯誤的。只需在此發佈以確認這是一個錯誤。 ChoiceType ::類Symfony ChoiceType選擇標籤不接受字符串作爲值
$choice1 = new \stdClass();
$choice1->name = 'Shipping';
$choice1->label = 'Shipping for you';
$choice1->code = 'xyz';
$builder
->add('modeOfDelivery', ChoiceType::class, [
'choices' => [
$choice1
],
'choice_label' => 'label',
'choice_value' => 'code'
])
;
當試圖用一個字符串作爲CHOICE_LABEL值我得到這個PHP的錯誤:Expected argument of type "null or callable", "string" given
/symfony中/ symfony中/ src目錄/ Symfony的/分量/表格/選擇列表/第70行的ArrayChoiceList.php -
public function __construct($choices, $value = null)
{
if (null !== $value && !is_callable($value)) {
throw new UnexpectedTypeException($value, 'null or callable');
}
任何幫助將不勝感激。