Forms: classic editor pick-existing-form modal with inline ref preview#48082
Forms: classic editor pick-existing-form modal with inline ref preview#48082
Conversation
…g-form modal
Classic Editor now opens a modal that lets users pick an already-saved
jetpack_form post and insert a [contact-form ref="{id}"] shortcode
instead of scaffolding a fresh shortcode inline. Inserted references
preview the real form in an iframe via the existing preview URL (new
bare=1 mode strips theme chrome). The pencil on a ref-based preview
opens the form in its own editor. The media button, TinyMCE toolbar
button, and text-editor quicktag all route through the same modal.
Gated on the central-form-management feature flag — the buttons are
not registered at all when CFM is disabled. The legacy inline field
editor for already-present [contact-form][contact-field] shortcodes
is untouched.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.
Interested in more tips and information?
|
|
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖 Follow this PR Review Process:
If you have questions about anything, reach out in #jetpack-developers for guidance! |
Code Coverage SummaryCoverage changed in 4 files.
Full summary · PHP report · JS report If appropriate, add one of these labels to override the failing coverage check:
Covered by non-unit tests
|
| font: 18px/1 dashicons; | ||
| } | ||
|
|
||
| /* Pick-existing-form modal (classic editor). */ |
There was a problem hiding this comment.
Instead of so much custom CSS to re-create a new modal, could we use Thickbox instead? Much of the core functionality (plugins page for example) uses it as well for basic modals.
| body.jetpack-form-bare-preview input, | ||
| body.jetpack-form-bare-preview textarea, | ||
| body.jetpack-form-bare-preview select, | ||
| body.jetpack-form-bare-preview button { |
There was a problem hiding this comment.
Surprised not to have a tag here but seemed to not be possible to click links anyway.
If the whole iframe is disabled for interactions are these needed?
| </select> | ||
| </label> | ||
| <a class="button grunion-form-picker-new" href="{{ data.new_form_url }}" target="_blank" rel="noopener noreferrer"> | ||
| {{ data.labels.picker_new_form }} |
There was a problem hiding this comment.
We should indicate in the button that it opens in a new tab, or decide to open it in the same tab.
| body.jetpack-form-bare-preview .wp-block-button__link, | ||
| body.jetpack-form-bare-preview .wp-element-button, | ||
| body.jetpack-form-bare-preview button[type="submit"] | ||
| ) { |
There was a problem hiding this comment.
Is the problem just outset, and why the rest of the styles then here too?
I don't fully understand the problem this CSS solves and ideally we'd have as little CSS like this around so looking for a way to reduce :-)
| $rendered_form = (string) ob_get_clean(); | ||
|
|
||
| // Form frontend stylesheet. | ||
| wp_enqueue_style( 'grunion.css' ); |
There was a problem hiding this comment.
Would it help to enqueue button block styles here if they aren't loaded otherwise?





Fixes FORMS-642
Proposed changes
[contact-form]…[/contact-form]shortcode inline.jetpack_formposts (fetched via/wp/v2/jetpack-forms), previews the selected form in an iframe, and inserts a[contact-form ref="{id}"]shortcode on confirm.wp-admin/post-new.php?post_type=jetpack_formso users create new forms in the real forms editor.[contact-form ref="{id}"]references now render the real form in the TinyMCE view via an iframe loading the existing preview URL with a new&bare=1mode that strips theme chrome but keeps all block/theme CSS. The pencil on a ref-based preview opens the form editor (wp-admin/post.php?post={id}&action=edit) in a new tab.central-form-managementfeature flag: when CFM is disabled, no button is registered — the legacy inline shortcode editor for existing[contact-form][contact-field …]content is left completely untouched so older sites keep working.Modal: Form picker
Form in the editor is a preview of the form. You can click the little pencil which takes you to the form editor for that form.
Related product discussion/links
Does this pull request change what data or activity we track or use?
No — reuses the existing preview nonce +
edit_postcapability check for the bare-preview query.Testing instructions
Setup
jetpack_formpost published via the Forms dashboard (or create one from the modal's empty state).Primary path — new insertion flow
post-new.php?post_type=jetpack_formin a new tab.[contact-form ref="{id}"]lands in the editor. The inline TinyMCE preview should render the real form (fields + submit button). Publish and view on the frontend to confirm the form renders.contact formquicktag → same modal opens; inserting usesQTags.insertContent.Ref-based inline preview
[contact-form ref="{id}"]in the post, switch to Visual mode. The TinyMCE view should show the full form rendered inline, not a generic placeholder.post.php?post={id}&action=editin a new tab; the view exits edit mode cleanly in the post.Legacy behavior preserved
[contact-form]…[contact-field …]…[/contact-form](noref), the inline field editor (pencil) should still work exactly as before — add/remove/reorder fields in the iframe editor.CFM disabled
add_filter( 'jetpack_forms_alpha', '__return_false' );via an mu-plugin (or equivalent). Reload the editor. The Add Contact Form media button, TinyMCE toolbar button, and quicktag should all be absent; the legacy inline editor for existing shortcodes continues to work.Empty state
jetpack_formposts, open the modal → empty state with Create a new form button linking topost-new.php?post_type=jetpack_form. No insert button is shown.Cross-browser