drupal: Form API, dynamically hide or show fields based on input(drupal:表单API,根据输入动态隐藏或显示字段)
问题描述
我正在构建一个表单模块.早期的字段之一是一组单选按钮.默认情况下,第一个按钮被选中.接下来,我将有一系列选择框.一个需要可见,其他需要不可见.然后当用户选择不同的单选按钮时,我希望显示或隐藏不同的选择框.如何在默认情况下隐藏字段和标签并稍后根据选择的单选按钮(或其他选择框选项)显示它?
I'm building a form module. One of the early fields is a set of radio buttons. By default the first button is selected. Next I'll have a series of select boxes. One needs to be visible, the others invisible. Then as the user selects a different radio button I want different select boxes to show or hide. How can I hide the field and label by default and show it later dependent upon which radio button (or another select box option for that matter) is chosen?
推荐答案
您可以使用 #states
属性来实现这一点.#states
属性可以应用于所有表单 API 元素.
You can use the #states
property to achieve that. The #states
property can be applied to all Form API elements.
这是文档链接一个例子.
这篇关于drupal:表单API,根据输入动态隐藏或显示字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:drupal:表单API,根据输入动态隐藏或显示字段


- Laravel 5:Model.php 中的 MassAssignmentException 2021-01-01
- 如何在 Symfony2 中正确使用 webSockets 2021-01-01
- 使用 GD 和 libjpeg 支持编译 PHP 2022-01-01
- 如何使用 Google API 在团队云端硬盘中创建文件夹? 2022-01-01
- 如何从数据库中获取数据以在 laravel 中查看页面? 2022-01-01
- PHP foreach() 与数组中的数组? 2022-01-01
- PHP - if 语句中的倒序 2021-01-01
- openssl_digest vs hash vs hash_hmac?盐与盐的区别HMAC? 2022-01-01
- Oracle 即时客户端 DYLD_LIBRARY_PATH 错误 2022-01-01
- 覆盖 Magento 社区模块控制器的问题 2022-01-01