2017-03-16 4 views
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' 
    ]) 
; 

나는이 PHP 오류 얻을 CHOICE_LABEL에 대한 값으로 문자열을 사용하려고 시도 : 공급 업체에 Expected argument of type "null or callable", "string" given

을/심포니/심포니/SRC/심포니/컴포넌트/양식/ChoiceList/ArrayChoiceList.php at line 70 -

public function __construct($choices, $value = null) 
    { 
     if (null !== $value && !is_callable($value)) { 
      throw new UnexpectedTypeException($value, 'null or callable'); 
     } 

도움을 주시면 감사하겠습니다.

답변

1

choices_as_values ​​옵션이 없습니다. 이 옵션은 오브젝트를 선택 사항으로 사용하기 위해 버전 2.8에서 필요합니다.