-
Notifications
You must be signed in to change notification settings - Fork 4.7k
PHP-only blocks: Generate inspector controls from attributes #74102
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Size Change: +358 B (+0.01%) Total Size: 2.59 MB
ℹ️ View Unchanged
|
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
packages/block-editor/src/hooks/generate-fields-from-attributes.js
Outdated
Show resolved
Hide resolved
mcsf
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking forward to this one.
packages/block-editor/src/hooks/generate-fields-from-attributes.js
Outdated
Show resolved
Hide resolved
packages/block-editor/src/hooks/generate-fields-from-attributes.js
Outdated
Show resolved
Hide resolved
…ing inspector control
38f8480 to
682ffb5
Compare
mcsf
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is looking great. 🚢
packages/block-editor/src/hooks/generate-fields-from-attributes.js
Outdated
Show resolved
Hide resolved
|
How much of the DataForm Fields API is now considered "stable" (no breaking change) after this merge? cc @oandregal |
What?
Part of #71792, related to #73845
Adds automatic DataForm inspector controls for PHP auto-registered blocks.
Why?
PHP-only blocks currently have no way to edit their attributes in the editor. This PR enables the automatic generation of inspector controls from the block's attribute definitions, making PHP-only blocks more useful and dynamic.
How?
On the PHP side,
gutenberg_mark_auto_inspector_control_attributesmarks user-defined attributes with__experimentalAutoInspectorControlduring block registration. This runs before block supports add their attributes, so only user-defined attributes are marked (why this is important: the first version of this implementation incorrectly generated inspector controls for block supports, too).On the client,
generateFieldsFromAttributesin theblock-editorpackage converts marked attributes to DataForm field definitions based on their types. This is necessary to keep this API close toblock.json, as they slightly diverge with the Field API.string→ text fieldnumber→ number fieldinteger→ integer fieldboolean→ boolean fieldstringwithenum→ select fieldThis will be obsolete once #74105 lands
source(attributes edited inline)role: 'local'(internal state like media uploads)Testing Instructions
Screencast
Grabacion.de.pantalla.2025-12-18.a.las.13.32.20.mov
Follow-ups