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 孟德尔随机化r语言运行问题
  • ¥15 pyinstaller编译的时候出现No module named 'imp'
  • ¥15 怎么把多于硬盘空间放到根目录下
  • ¥15 Matlab问题解答有两个问题
  • ¥50 Oracle Kubernetes服务器集群主节点无法访问,工作节点可以访问
  • ¥15 LCD12864中文显示
  • ¥15 在使用CH341SER.EXE时不小心把所有驱动文件删除了怎么解决
  • ¥15 gsoap生成onvif框架
  • ¥15 有关sql server business intellige安装,包括SSDT、SSMS。
  • ¥15 stm32的can接口不能收发数据