內容簡介
摘要:
Contact Form 7 是一個優秀的 WordPress 外掛程式,也是免費 WordPress 外掛程式中,最佳的聯絡表單選擇之一。Controller Fields 能夠為它添加動態內容功能,提供新的表單標籤,可用於控制其他欄位和內容的顯示,包括基於下拉菜單的當前值隱藏或顯示額外表單欄位、基於勾選框點擊隱藏或顯示內容,以及基於當前選定的單選按鈕隱藏或顯示信息,並可以嵌套控制和受控欄位。總之,使用此外掛程式會有無盡的可能性。
使用方式:
此外援程式創建三 (3) 個新表單標籤,用於控制其他表單標籤的顯示 (又稱“控制器”),以及一個特殊的表單標籤生成器按鈕,用於輸出所需的 HTML 包裝以包裝可控表單標籤。安裝並啟用此外掛程式後,創建或編輯 Contact Form 7 表單時,您將在頂部看到四個 (4) 個新按鈕:選擇控制器、勾選框控制器、單選按鈕控制器和受控表單標籤包裝器。它們的標籤生成器中的大多數選項將對 Contact Form 7 使用者來說是耳熟能詳的,但有一些升級。
問題與答案:
問題:何謂 Controller Fields 外掛程式?
答案:Controller Fields 是一個外掛程式,可以為 Contact Form 7 添加動態內容功能。
問題:Controller Fields 外掛程式如何實現控制表單欄位顯示?
答案:此外掛程式提供新的表單標籤,用於控制下拉菜單、勾選框和單選按鈕的顯示,以控制其他欄位和內容的顯示。
問題:使用 Controller Fields 外掛程式如何創建控制器?
答案:在安裝並啟用此外掛程式後,創建或編輯 Contact Form 7 表單時,您將看到四個新按鈕:選擇控制器、勾選框控制器、單選按鈕控制器和受控表單標籤包裝器,它們將用於創建控制器。
問題:如何在 Controller Fields 外掛程式中設置選項?
答案:此外掛程式提供三種定義選項的方法,第一種方法是簡單地輸入選項,每個選項都在新行中,例如:蘋果、香蕉、火龍果。第二種方法類似,但它允許您使用“|”分隔符,以更好地控制值和標籤,例如:fruit_1 | Apples、fruit_2 | Bananas、fruit_3 | Dragonfruit。第三種方法是基於動態生成,可以使用短代碼填充選項。
問題:如何在 Controller Fields 外掛程式中設置默認值?
答案:此欄位可以接受靜態文本或短代碼。如果使用短代碼,則與選項欄位中的語法相同,但此欄位還需要更多需求。
問題:Controller Fields 外掛程式中如何設置占位符?
答案:此外掛程式僅適用於選擇控制器表單標籤,此欄位可以接受靜態文本或短代碼。如果使用短代碼,則與選項欄位中的語法相同,但此欄位還需要更多需求。
問題:如何禁用表單的某個欄位?
答案:只需選中“Read Only Attribute”或“Disabled Attribute”的框即可禁用表單中的欄位。
外掛標籤
開發者團隊
② 後台搜尋「Controller Fields for Contact Form 7」→ 直接安裝(推薦)
原文外掛簡介
Contact Form 7 is an excellent WordPress plugin and one of the top choices of free WordPress plugins for contact forms. Controller Fields makes it even more awesome by adding dynamic content capabilities. This plugin provides new form tags for select fields, checkboxes, and radio buttons so you can use them to control the display of other fields and content. Some examples might include:
Hiding or revealing additional form fields based the current value in a dropdown
Hiding or revealing content when users click a checkbox
Hiding or revealing information based on which radio button is currently selected
Controllers and controlled fields can be nested
The possibilities are endless!
View Demo
Preview this plugin in the WordPress Playground, a sandbox environment where you can explore the features of this plugin, both in the WordPress backend as an admin user and on the frontend.
WHAT DOES IT DO?
This plugin creates three (3) new form tags for controlling the appearance of other form tags (aka “controller”) and a special form tag generator button to output the HTML needed to wrap the controllable form tags inside.
HOW TO USE IT
After installing and activating the plugin, you will have four (4) new buttons at the top when creating or editing a Contact Form 7 form: select controller, checkbox controller, radio controller, and controlled form tag wrapper. Most of the options in their tag generators will be familiar to Contact Form 7 users but there have been some upgrades.
Id Attribute
The frontend script relies on unique IDs for the controller form tags, so be sure to always set one!
Options
There are three (3) ways you can define your options. The first method is simply typing your options with each one on a new line, e.g.:
Apples
Bananas
Dragonfruit
The second method is similar, but it allows you more control over the value and label by using | to separate them, e.g.:
fruit_1 | Apples
fruit_2 | Bananas
fruit_3 | Dragonfruit
The third method is dynamic in that you can use a shortcode to populate your options with two important provisions:
The shortcode should NOT include the normal square brackets ([ and ]). So, instead of [my_shortcode key='value'] you would use my_shortcode key='value'.
Any parameters in the shortcode must use single quotes. That is: my_shortcode key='value' and not my_shortcode key="value"
Shortcodes used here should return a string value with the option or option group HTML.
Default value
This field can take static text or a shortcode. If using a shortcode, the same syntax applies from the options field. However, this field also has a few more needs:
The text/shortcode must first have apostrophes converted to it’s HTML entity code, '
After that, it must be URL encoded so that spaces become %20 and other non-alphanumeric characters are converted.
Placeholder
Only available for the select controller form tag, this field can take static text or a shortcode. If using a shortcode, the same syntax applies from the options field. However, this field also has a few more needs:
The text/shortcode must first have apostrophes converted to it’s HTML entity code, '
After that, it must be URL encoded so that spaces become %20 and other non-alphanumeric characters are converted.
Read Only Attribute
Simply check this box if you do not want to let users edit this field. It will add the readonly attribute to your form field.
Disabled Attribute
Simply check this box if you do not want to submit this field in the form. It will add the disabled attribute to your form field.
