Skip to main content
Using the 'form' Dynamic Shortcodes in Dynamic Content for Elementor
Updated over 6 months ago

Starting from version 3.0, Dynamic Content for Elementor introduced a series of Dynamic Shortcodes specifically designed to interact with Elementor Pro Forms.

These Dynamic Shortcodes are intended to be used with various features of Dynamic Content for Elementor that integrate with Elementor Pro Form, providing users with sophisticated tools for dynamic data manipulation.

Available Dynamic Shortcodes 'form' and Their Outputs

The Dynamic Shortcodes for Elementor Pro Forms enable access and manipulation of form data in various ways. Here is an overview of the available dynamic shortcodes and what they output:

  • {form:field}

    • Output: Returns the value of a specific form field as a string. If the field allows multiple selections (such as a checkbox), the selected values are returned as a single string, separated by commas.

    • Usage: {form:field}, where field is the ID of the desired field.

  • {form:field@raw}

    • Output: Returns the original raw value of fields like checkboxes, which allow multiple selections. This means that instead of a single string, it outputs a PHP array of the selected options, such as ['a', 'b', 'c']. This is especially beneficial for custom processing or when you need to handle the data programmatically, as it preserves the array structure.

    • Usage: {form:field@raw}, where field is the ID of the desired field. This version of the dynamic shortcode provides the raw data, which is crucial for specific backend processes or advanced data handling scenarios.

  • {form:all-fields}

    • Output: Retrieves all fields of the form, formatted and separated appropriately based on the form's layout.

    • Usage: {form:all-fields} is used to display all form fields in a formatted string.

  • {form:all-fields@not-empty}

    • Output: Similar to {form:all-fields}, but only includes fields that have been filled out, ensuring that empty fields are omitted from the output.

    • Usage: {form:all-fields@not-empty} is ideal for summaries or reports where only completed fields are necessary.

  • {form:array}

    • Output: Returns an array that contains all the form fields. This can be iterated over with a loop for further manipulation or customized display.

    • Usage: {form:array} can be used in advanced customizations where developers need to loop through all fields programmatically.

Practical Examples of Using Dynamic Shortcodes

These dynamic shortcodes open up a range of possibilities for displaying and processing form data dynamically. Here are some practical examples:

  • Display a field only if it is not empty:

    {if:{form:field} {form:field}}

    This checks if the field is not empty and displays its content.

  • Display a field if not empty; otherwise, display another field:

    {if:{form:field} {form:field} {form:another-field}}

    This checks if the first field is not empty and displays it; otherwise, it shows the content of another field.

  • Display a field if not empty; otherwise, display a custom string:

    {if:{form:field} {form:field} 'The Field is empty'}

    If the field is not empty, it displays its content; otherwise, it outputs a custom message stating "The Field is empty."

Did this answer your question?