

Symfony2.3のシステムをSymfony3へアップデートし、動作を確認しております。  
フォーム作成ページにアクセスしたところ、下記エラーが出ました。  
Symfony3.0以降でchoice_listは使えなくなり、`choices`か`choice_loader`を試したのですが、typeが異なるようで、コードの変更をどのようにしていいか分かりません。  
修正のアイデアをいただきたいです。

<https://symfony.com/doc/2.8/reference/forms/types/choice.html#choice-list>  
**Error**

[code]

    The option "choice_list" does not exist. Defined options are: "action", "allow_extra_fields", "allow_file_upload", "attr", "auto_initialize", "block_name", "by_reference", "choice_attr", "choice_label", "choice_loader", "choice_name", "choice_translation_domain", "choice_value", "choices", "choices_as_values", "class", "compound", "constraints", "csrf_field_name", "csrf_message", "csrf_protection", "csrf_token_id", "csrf_token_manager", "data", "data_class", "disabled", "em", "empty_data", "error_bubbling", "error_mapping", "expanded", "extra_fields_message", "group_by", "id_reader", "inherit_data", "invalid_message", "invalid_message_parameters", "label", "label_attr", "label_format", "mapped", "method", "multiple", "placeholder", "post_max_size_message", "preferred_choices", "property_path", "query_builder", "required", "translation_domain", "trim", "upload_max_size_message", "validation_groups".
    
[/code]

**Code**  
StaffChoiceList.php

[code]

    <?php
    namespace Ahi\Sp\AdminBundle\Form\ChoiceList;
    
    use Symfony\Component\Form\Extension\Core\ChoiceList\ChoiceList;
    use Symfony\Component\Form\ChoiceList\LazyChoiceList;
    
    class StaffChoiceList extends LazyChoiceList
    {
        private $staffService;
    
        private $loginStaff;
    
        private $currentStaff;
    
        public function __construct($staffService, $loginStaff)
        {
            $this->staffService = $staffService;
            $this->loginStaff = $loginStaff;
        }
    
        public function setCurrentStaff($currentStaff)
        {
            $this->currentStaff = $currentStaff;
        }
    
        protected function loadChoiceList()
        {
            // ログインスタッフと同じショップのスタッフを取得
            $staffs = $this->staffService->getStaffByShop($this->loginStaff->getShop());
    
            // 現在のスタッフが(転勤などにより)取得したスタッフに含まれない場合は末尾に追加
            if ($this->currentStaff && !array_search($this->currentStaff, $staffs)) {
                $staffs[] = $this->currentStaff;
            }
            return new ChoiceList($staffs, $staffs);
        }
    }
    
    
[/code]

ArticleType.php

[code]

            // 投稿者
            $authorChoiceList = new StaffChoiceList($this->staffService, $options['login_staff']);
            $builder->add("author", EntityType::class, array(
                "required" => true,
                "class" => "AhiSpCommonBundle:Staff",
                "choice_list" => $authorChoiceList,   //エラー箇所
                "placeholder" => "選択してください",
            ));
    // submit
            $staff = $options['login_staff'];
            if ($staff->getShop() && $staff->getShop()->getApprovalFlg()) {
                // 承認機能を使用するショップの場合
                if ($staff->isManage()) {
                    // ショップ管理者 (下書き保存、承認待ち、即時投稿)
                    $builder->add("draft", SubmitType::class);
                    $builder->add("approvalRequest", SubmitType::class);
                    $builder->add("publish", SubmitType::class);
                } else {
                    // 一般スタッフ (下書き保存、承認待ち)
                    $builder->add("draft", SubmitType::class);
                    $builder->add("approvalRequest", SubmitType::class);
                }
            } else {
                // 本部管理画面または承認機能を使用しないショップの場合 (下書き保存、投稿)
                $builder->add("draft", SubmitType::class);
                $builder->add("publish", SubmitType::class);
            }
    
            // イベント処理
            $builder->addEventSubscriber(new RelatedArticlesSubscriber($this->em));
            $builder->addEventSubscriber(new TrendTagsSubscriber($this->em));
            $builder->addEventSubscriber(new ArticleStatusSubscriber());
    
            $builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) use ($authorChoiceList) {
                $article = $event->getData();
                $authorChoiceList->setCurrentStaff($article->getAuthor());
            });
        public function configureOptions(OptionsResolver $resolver)
        {
            $resolver->setRequired(array(
                "login_staff",
            ));
        }
    
[/code]

**試したこと**  
`choices`に変更したところ、下記エラーが出ます。

[code]

    The option "choices" with value Ahi\Sp\AdminBundle\Form\ChoiceList\StaffChoiceList is expected to be of type "null" or "array" or "\Traversable", but is of type "Ahi\Sp\AdminBundle\Form\ChoiceList\StaffChoiceList".
    
[/code]

**Version**  
Cent OS 6.7  
PHP 5.6  
Symfony 3.0.9


CC BY-SA 4.0
2021-01-07T06:17:57.270
73136
2021-01-08T06:59:36.867
2021-01-08T06:59:36.867
42407
42407
question
php symfony
SymfonyでThe option "choice_list" does not exist.のエラー