Skip to content

BooleanWidget and clarify widgets definitions in documentation - #8309

Closed
sneridagh wants to merge 5 commits into
sevenfrom
widgetsDefinitions
Closed

sneridagh wants to merge 5 commits into
sevenfrom
widgetsDefinitions

Conversation

@sneridagh

Copy link
Copy Markdown
Member

Supersedes: #8237 and #8247

@sneridagh

Copy link
Copy Markdown
Member Author

@pnicolli damn, I kept thinking about it and went through all the current widgets that we have, and it's harder than I thought... it definitelly needs more love. Only alone the use case for public forms is a thing we have to address.

@pnicolli pnicolli left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah it needs more love, but I think starting with a good documentation of what we want to achieve is a good starting point to actually achieve consistent behavior in widgets and better code quality. It might be challenging and we might end up adapting these docs to actually match what we need, but I think it's a good starting point.

Comment thread docs/conceptual-guides/form-fields-controls-and-widgets.md Outdated
A field is the form-level representation of one piece of content data.
It has a name, a current value, validation state, and schema metadata.
In a content form, a field usually comes from a Plone schema property.
For example, `title`, `description`, `effective`, and `is_folderish` are fields when the form renders them as editable metadata.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure we should include is_folderish in this example

Comment on lines +64 to +70
## Adapter

An adapter is a wrapper that turns a control into a widget.
It maps the form field contract to the control contract.
This is the right place to translate names, normalize values, and convert validation metadata into the shape expected by the control.

For example, a boolean widget can adapt a checkbox control by mapping `value` to `isSelected` and by mapping `onChange(value)` to the checkbox's selected state callback.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand how this is different from the Widget definition.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought that would make sense, but if we standardize and further fully specify what is a widget-able component and what is not, we might get away only with one. It also came from the fact of having "half way threre" components in @plone/components that might need an adapter... but it's true that we could make them behave fully with our canonical widget definition specs, and that's it.


```tsx
function BooleanWidget(props: FormWidgetProps<boolean>) {
return null;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If what you wanted here is to avoid focusing on what is the code of the function, I would just write the function signature, like

function BooleanWidget(props: FormWidgetProps<boolean>)

or something like this

function BooleanWidget(props: FormWidgetProps<boolean>) {
  // ...
}

with return null I was like "wth" for a moment and I can only assume I won't be the only one


Registering those controls directly makes the form generator depend on many incompatible prop conventions.
That weakens the registry because the registry can no longer promise what a widget receives or returns.
Adapters keep the boundary explicit.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why? But my question might come from the fact that I didn't understand adapters, see my other question above

Comment thread docs/conceptual-guides/form-fields-controls-and-widgets.md Outdated
Comment thread docs/conceptual-guides/form-fields-controls-and-widgets.md Outdated
Seven forms are schema-driven.
A content schema describes metadata fields, and the CMS UI turns those fields into interactive form elements.
This process is intentionally split into several concepts: fields, controls, widgets, and adapters.
The distinction matters because not every visual input component can be registered directly as a CMS widget.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CMS or CMSUI?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I rephrased it.

Comment thread docs/conceptual-guides/form-fields-controls-and-widgets.md Outdated
Comment thread docs/conceptual-guides/form-fields-controls-and-widgets.md Outdated
Comment thread docs/conceptual-guides/form-fields-controls-and-widgets.md Outdated
* seven:
  Update README with the Plone Aurora
  Seven querystringWidget (#8017)
  [Seven] Add `renderEmptyState` to `Table` component (#8308)
  Recurrence widget (#7200)
sneridagh and others added 2 commits June 4, 2026 12:21
Co-authored-by: Steve Piercy <web@stevepiercy.com>
@sneridagh

Copy link
Copy Markdown
Member Author

Moving it to plone/aurora#97

@sneridagh sneridagh closed this Jun 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants