title: Custom Choice type with parameters
body: <p>I make my custom ChoiceType</p>
  <pre><code>class CountryType extends ChoiceType
  {
  
      public function configureOptions(OptionsResolver $resolver): void
      {
          parent::configureOptions($resolver);
          $resolver-&gt;setDefaults([
              'choices'      =&gt; $this-&gt;locationService-&gt;getCountries(),
          ]);
      }
  }
  
  class StateType extends ChoiceType
  {
  
      public function configureOptions(OptionsResolver $resolver): void
      {
          parent::configureOptions($resolver);
          $choices = isset($countryId)? $this-&gt;locationService-&gt;getStatesByCountryId($countryId):[]; &lt;---
  
          $resolver-&gt;setDefaults([
              'choices' =&gt; $choices,
          ]);
      }
  }
  
  class FormType extends AbstractType
  {
  
      public function buildForm(FormBuilderInterface $builder, array $options): void
      {
          $builder-&gt;add('country', CountryType::class, [
                  'label'    =&gt; 'Country',
                  'required' =&gt; false,
              ])-&gt;add('state', StateType::class, [
                  'label'    =&gt; 'State',
                  'required' =&gt; false,
              ]);
      }
  
      public function configureOptions(OptionsResolver $resolver): void
      {
          $resolver-&gt;setDefaults([
              'data_class'        =&gt; FormRequest::class,
              'validation_groups' =&gt; [],
          ]);
      }
  }
  </code></pre>
  <p>But for StateType optionally (when I edit entity) I need <strong>$countryId</strong> how I can put it? Maybe with options or choice_loader?</p>
  <p>I also tried to crank out such an idea, but as I understand it, this is not possible</p>
  <pre><code>                         {{ form_widget(form.state, {
                              'countryId': form.country.vars.value,
                           }) }}    
  
             
  </code></pre>