drupal:Form API,根据输入动态隐藏或显示字段 [英] drupal: Form API, dynamically hide or show fields based on input
问题描述
您可以使用 #states
属性来实现。 #states
属性可以应用于所有Form 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?
You can use the #states
property to achieve that. The #states
property can be applied to all Form API elements.
Here's the documentation link with an example.
Hope this helps... Muhammad.
这篇关于drupal:Form API,根据输入动态隐藏或显示字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!