You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
{{< form background=`#1D1F26` style=`rounded-boxed` netlify=true conditional-form=true >}}
<!-- Form content goes here -->
{{< /form >}}
background: Sets the background color of the form.
style: Applies a predefined style to the form (e.g., rounded-boxed).
netlify: Enables form submission through Netlify.
conditional-form: Enables conditional logic within the form.
2. Text Input
Creates a text input field with various attributes.
Formula <br/>
((Number of Pages \* 1 day) + (Number of Features \* 2 days)) / Number of Developers
<divclass="row g-0 not-prose">
<divclass="col-xl-6">
{{< form background=`#1D1F26` style=`rounded-boxed` conditional-form=true >}} {{< input-text type=`number` label=`Number of Pages` id=`number-of-pages` name=`number-of-pages` condition=`calc/add:project-duration` >}} {{< input-text type=`number` label=`Number of Features` id=`number-of-features` name=`number-of-features` condition=`calc/add:project-duration` >}} {{< input-text type=`number` label=`Number of Developers` id=`number-of-developers` name=`number-of-developers` value=`1` min=`1` condition=`calc/add:project-duration` >}} {{< input-calc-result title=`Total Duration` append=`Day` prepend=`` id=`project-duration` formula=`(({number-of-pages}*1)+({number-of-features}*2))/{number-of-developers}` conditional-element=true >}} {{< button-submit value=`Submit` >}}{{< /form >}}
</div>
</div>
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:
match: condition="match/value:target-id" - Displays the target element when the current element's value matches the specified value.
multiple match: condition="match/value:target-id;condition="match/value:target-id" - Allows multiple conditions separated by semicolons.
checked: condition="checked:target-id" - Shows the target element when the checkbox or radio button is checked; hides it otherwise.
calc: condition="calc/mathematical-operation:target-id" - Incorporates the current element's value into calculations for the target element:
Available mathematical operations include add, sub, mul, and div.
The text was updated successfully, but these errors were encountered:
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
.The text was updated successfully, but these errors were encountered: