doupu3635 2017-04-04 11:48
浏览 25
已采纳

如何添加依赖于另一个的选择下拉列表?

I've a form with 2 dropdown lists. The first one with molecule families and the second with molecule subgroup. When someone choose a family, he should only see the subgroups related to this family in the second dropdown.

enter image description here

My Form Type:

public function buildForm(FormBuilderInterface $builder, array $options)
{
    $builder
        ->add('Families', ChoiceType::class, array(
            'choices' => array(
                'Monosaccharides' => 'Monosaccharides',
                'Oligosaccharides ' => 'Oligosaccharides ',
                'Polysaccharides' => 'Polysaccharides'
            ),
            'placeholder' => 'Choose an option',
            'required' => false
        ))
        ->add('MolecularGroups', ChoiceType::class, array(
            'choices' => array(
                'Monosaccharide' => 'Monosaccharide',
                'Oligosaccharide' => 'Oligosaccharide',
                'Cyanogenic glycoside' => 'Cyanogenic glycoside'
            ),
            'placeholder' => 'Choose an option',
            'required' => false
        ));
}

Can someone show me the Symfony documentation about how to implement that?

  • 写回答

1条回答 默认 最新

  • dongsaolian8786 2017-04-04 12:31
    关注

    The Question:

    Can someone show me a documentation on how to do that?

    The Documentation references:

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 关于#java#的问题,请各位专家解答!
  • ¥15 急matlab编程仿真二阶震荡系统
  • ¥20 TEC-9的数据通路实验
  • ¥15 ue5 .3之前好好的现在只要是激活关卡就会崩溃
  • ¥50 MATLAB实现圆柱体容器内球形颗粒堆积
  • ¥15 python如何将动态的多个子列表,拼接后进行集合的交集
  • ¥20 vitis-ai量化基于pytorch框架下的yolov5模型
  • ¥15 如何实现H5在QQ平台上的二次分享卡片效果?
  • ¥30 求解达问题(有红包)
  • ¥15 请解包一个pak文件