Open tfsumon opened 4 months ago
@tfsumon , to be able to use these dynamic forms, which files do I have to touch in which folders?
I've added a dynamic form shortcode to the content/english/dynamic-form.md
file. You can use any of the shortcodes defined in this markdown file within other files.
Hugo Shortcodes Documentation for Conditional Forms
This guide provides a comprehensive explanation of how to use Hugo shortcodes to create dynamic forms with conditional fields, radio buttons, checkboxes, and calculated fields. The shortcodes and their corresponding HTML templates work together to create a seamless user experience.
Shortcodes and Examples
1. Form Container
The form container shortcode sets the background, style, and other attributes of the form.
rounded-boxed
).2. Text Input
Creates a text input field with various attributes.
3. Select Dropdown
Creates a select dropdown menu with conditional attributes.
4. Conditional Elements
Elements that are displayed or hidden based on conditions.
5. Radio Button Group
Creates a group of radio buttons with conditional logic.
6. Submit Button
Creates a submit button with customizable attributes.
Example Usage in a Form
Here is a complete example of how to use these shortcodes within a form:
Feedback Form
Empower Engineers - Service Request Form
Project Initiation Form
Selecting Web Design Themes
Calculating Project Cost
Estimating Project Duration
Explanation of Key Attributes
formula: Defines a mathematical formula used to calculate values within the form. The syntax is
formula="({input-id1}*value1)+({input-id2}*value2)/{input-id3}"
. Input IDs enclosed in curly braces are dynamically replaced with user-entered values from corresponding form elements, enabling real-time calculations.condition: Specifies conditions under which a form element should appear or remain hidden based on the value of another form element:
condition="match/value:target-id"
- Displays the target element when the current element's value matches the specified value.condition="match/value:target-id;condition="match/value:target-id"
- Allows multiple conditions separated by semicolons.condition="checked:target-id"
- Shows the target element when the checkbox or radio button is checked; hides it otherwise.condition="calc/mathematical-operation:target-id"
- Incorporates the current element's value into calculations for the target element:add
,sub
,mul
, anddiv
.