Fieldset grouping, ordering, and conditional visibility for volto-form-block.
This addon extends volto-form-block (v3.14.0+) with the ability to visually group form fields into fieldsets. Editors can define fieldsets in the block sidebar, assign fields to them, drag fieldsets to control the page order, and optionally show or hide entire fieldsets based on the value of another field.
Key features:
- Fieldset grouping -- define named groups and assign fields to them
- Drag-to-reorder -- fieldset order in the sidebar controls render order on the page
- Show/hide border -- fieldsets can render as bordered groups with a legend, or as invisible wrappers (useful for standalone fields that need to sit between bordered groups)
- Conditional fieldsets -- show or hide an entire fieldset based on another field's value, using the same visibility conditions system that volto-form-block uses for individual fields
- Visibility-aware validation -- required fields inside hidden fieldsets are skipped during validation
- Pure frontend -- no backend changes required; fieldset data is stored as part of the block's JSON
The addon makes four changes to the form block's configuration:
- Enhanced formSchema -- adds a "Fieldsets" tab in the form block sidebar where editors manage fieldsets using Volto's ObjectListWidget (which supports drag-to-reorder out of the box)
- Enhanced fieldSchema -- adds a "Fieldset" dropdown to each field's settings panel
- Custom FormView (via Volto component shadowing) -- renders fields grouped by fieldset in the defined order, with optional
<fieldset>wrapper and conditional visibility - Custom Sidebar (via Volto component shadowing) -- passes the current fieldset definitions to the field schema so the dropdown stays in sync
- Custom View (via Volto component shadowing) -- skips validation for fields hidden by visibility conditions
Fieldset definitions are stored on the block data:
{
"fieldsets": [
{ "id": "details", "title": "Your details", "show_border": true },
{ "id": "study-question", "title": "Study question", "show_border": false },
{
"id": "education",
"title": "Education",
"show_border": true,
"visibility_conditions": [
{ "field_id": "have_you_studied", "condition": "is_equal_to", "value_condition": true }
]
}
]
}Each field (subblock) gets a fieldset_id property:
{ "label": "Full name", "field_type": "text", "fieldset_id": "details" }- Plone 6 with Volto 18+
- volto-form-block 3.14.0+
- collective.volto.formsupport 3.0+ (backend)
In your project's package.json:
{
"dependencies": {
"volto-form-block": "3.14.0"
}
}Copy the following files into your project's site addon (e.g. volto-my-site):
src/
├── customizations/
│ └── volto-form-block/
│ ├── enhancedFormSchema.js
│ ├── enhancedFieldSchema.js
│ ├── fieldset.css
│ └── components/
│ ├── FormView.jsx
│ ├── Sidebar.jsx
│ └── View.jsx
All fieldset-related code lives under customizations/volto-form-block/. The components/ subfolder contains Volto component shadows that replace the originals. The schema files and CSS sit alongside them as part of the same customisation.
In your site addon's package.json, add volto-form-block to both addons and dependencies. This ensures it loads before your addon's config runs:
{
"addons": [
"volto-form-block"
],
"dependencies": {
"volto-form-block": "*"
}
}If you previously had volto-form-block in your project's volto.config.js, you can remove it from there.
Add the schema replacements and CSS import:
import EnhancedFormSchema from './customizations/volto-form-block/enhancedFormSchema';
import EnhancedFieldSchema from './customizations/volto-form-block/enhancedFieldSchema';
import './customizations/volto-form-block/fieldset.css';
const applyConfig = (config) => {
// ... your existing config ...
// Fieldset support
if (config.blocks.blocksConfig.form) {
config.blocks.blocksConfig.form.formSchema = EnhancedFormSchema;
config.blocks.blocksConfig.form.fieldSchema = EnhancedFieldSchema;
config.blocks.blocksConfig.form._currentFieldsets = [];
}
return config;
};
export default applyConfig;Note the if guard: it prevents errors if the form block hasn't loaded yet. With the addons dependency approach from step 3, this shouldn't happen, but it's a safe fallback.
yarn install
yarn startInstall collective.volto.formsupport if you haven't already. No additional backend changes are needed for fieldsets -- all fieldset data is stored in the block's JSON, which Plone handles automatically.
pip install "collective.volto.formsupport[honeypot]==3.3.0"Add to your instance.yaml:
zcml_package_includes:
- collective.volto.formsupport
- collective.honeypot- Add a Form block to a page
- Add your fields as usual (text, email, select, etc.)
- In the form block sidebar, click the Fieldsets tab
- Click Add item to create fieldsets (e.g. "Personal details", "Contact info")
- Give each fieldset a Title and optionally an ID (auto-generated from title if left empty)
- Click on each field in the sidebar accordion and select the appropriate Fieldset from the dropdown at the bottom of its settings
- Save the page
Fields will render grouped inside bordered <fieldset> elements with the fieldset title as a legend.
The order of fieldsets in the sidebar list controls the order they appear on the page. Use the drag handles on the ObjectListWidget items to reorder fieldsets.
Not every section needs a visible border. For example, a standalone checkbox between two bordered groups:
- Create a fieldset for the checkbox (e.g. "Study question")
- Set Show border and title to off
- Assign the checkbox to this fieldset
- Drag it between the other fieldsets in the list
The checkbox will render inline, without any wrapper, exactly where you placed the fieldset in the order.
Show or hide an entire fieldset based on another field's value:
- Create a checkbox field (e.g. "I have studied")
- Create an "Education" fieldset
- On the Education fieldset, click the Show fieldset when config icon
- Set the condition: If "I have studied" → Is equal to → Checked
- Assign your education-related fields to the Education fieldset
The entire Education section will appear only when the checkbox is ticked.
Fieldset order:
| # | Fieldset | Show border | Condition |
|---|---|---|---|
| 1 | Personal details | Yes | -- |
| 2 | Study question | No | -- |
| 3 | Education | Yes | "Have you studied?" is checked |
| 4 | Additional info | Yes | -- |
This renders as:
- A bordered "Personal details" group with name and email fields
- A standalone "Have you studied?" checkbox (no border)
- A bordered "Education" group that appears when the checkbox is ticked
- A bordered "Additional info" group
volto-form-block's built-in validation checks all required fields regardless of whether they're currently visible. This addon fixes that with a custom View.jsx that skips validation for fields that are hidden due to:
- The field's own visibility conditions not being met
- The field's parent fieldset's visibility conditions not being met
This means you can safely mark fields inside a conditional fieldset as required. They'll only be validated when the fieldset is visible.
| Package | Version |
|---|---|
| Plone | 6.0+ |
| Volto | 18.x |
| volto-form-block | 3.14.0+ |
| collective.volto.formsupport | 3.0+ |
- The addon uses Volto's component shadowing (customizations folder) to replace
FormView,Sidebar, andViewfrom volto-form-block. If you're already shadowing these components, you'll need to merge the changes. - Fieldset definitions are passed from the Sidebar to the fieldSchema via
config.blocks.blocksConfig.form._currentFieldsets. This is set on every render of the Sidebar component. - The existing
enableConditionalFieldsconfig flag (default:true) must be enabled for both field-level and fieldset-level visibility conditions to work. - Submitted form data is unaffected by fieldsets. The backend receives the same flat field list regardless of grouping.
| File | Purpose |
|---|---|
customizations/volto-form-block/enhancedFormSchema.js |
Adds "Fieldsets" tab to the form sidebar |
customizations/volto-form-block/enhancedFieldSchema.js |
Adds "Fieldset" dropdown to each field's settings |
customizations/volto-form-block/fieldset.css |
Minimal styling for the <fieldset> wrapper |
customizations/volto-form-block/components/FormView.jsx |
Renders fields grouped by fieldset with ordering, borders, and conditional visibility |
customizations/volto-form-block/components/Sidebar.jsx |
Passes fieldset definitions to the field schema |
customizations/volto-form-block/components/View.jsx |
Visibility-aware validation: skips required-field checks for hidden fields and fieldsets |