Form Element Improvements: Conditional Email Output, Custom Field Classes & Fieldsets

Hi Bricks team,

First of all, great work on the Form element – it’s already very useful and well integrated into the builder.

While working on multiple client projects, I ran into a few limitations that make more advanced and scalable form setups difficult. I’d like to suggest the following improvements:

1. Only send filled-out fields in email content

Currently, when using {{all_fields}}, all fields are included in the email – even if they are empty. This results in emails with many empty labels, which looks unprofessional.

Expected behavior:

  • Option to only include fields that contain values

  • Alternatively: conditional logic in the email content (e.g. show field only if not empty)

Attempted workaround:
I tried overriding via:

add_filter( ‘bricks/form/email_content’, … )

However, this does not seem to reliably override the default output (especially when using {{all_fields}} or empty email content).

A native solution would be much more robust and user-friendly.

2. Ability to add custom classes to form fields

Currently, there is no straightforward way to assign custom CSS classes directly to individual fields.

Why this matters:

  • Essential for advanced styling (especially in larger projects)

  • Needed for JS interactions (e.g. conditional fields, validation, tracking)

  • Improves scalability when reusing forms

Suggested solution:

  • Add a “Custom class” field in each form field’s settings

  • Similar to how classes can be added to other Bricks elements

3. Native support for fieldsets / grouped fields

There is currently no clean way to group fields semantically using <fieldset> and <legend>.

Use cases:

  • Grouping related fields (e.g. “Personal Info”, “Booking Details”)

  • Accessibility improvements

  • Better structure for complex forms

Current limitation:

  • Using an HTML element is not viable because it is wrapped in a .form-group div

  • This breaks proper semantic structure and layout control

Suggested solution:

  • Add a dedicated “Fieldset” element within the Form builder

  • Ability to nest fields inside it

  • Optional legend/title

Why this matters

These features would significantly improve:

  • Email clarity and professionalism

  • Developer control and flexibility

  • Scalability across multilingual and multi-project setups

  • Accessibility and semantic HTML structure

Summary of requested features

  • Option: “Only include filled fields” in email output

  • Support for conditional logic in email content (optional but powerful)

  • Custom CSS class field per form field

  • Native Fieldset/Group element with nesting support

Thanks for considering these improvements – they would make the Form element much more powerful for real-world use cases.

P.S.
Request has been optimized with ChatGPT :wink: