Skip to content

Add hidden field support to the experimental form block#70712

Closed
dhananjaykuber wants to merge 3 commits intoWordPress:trunkfrom
dhananjaykuber:feat/add-hidden-field-to-form
Closed

Add hidden field support to the experimental form block#70712
dhananjaykuber wants to merge 3 commits intoWordPress:trunkfrom
dhananjaykuber:feat/add-hidden-field-to-form

Conversation

@dhananjaykuber
Copy link
Copy Markdown
Contributor

Closes #57610

What?

Add hidden field support to the experimental form block, allowing users to include invisible form fields that are submitted with the form data.

Why?

Hidden fields are a fundamental requirement for modern web forms, especially when integrating with third-party services.

How?

The implementation adds a complete hidden fields management system:

Backend Changes:

  • New hiddenFields array attribute in block.json schema
  • Each field object contains id, name, and value properties
  • Block deprecation for backward compatibility with existing forms

Editor Experience:

  • New "Hidden fields" section in Inspector Controls Tools Panel
  • Add/remove interface

Testing Instructions

  • Open a post or page in the block editor
  • Insert a Form block
  • In the Inspector Controls sidebar, scroll to "Hidden fields" section
  • Click "Add hidden field" button
  • Enter field name: source and value: website
  • Add a second field with name: campaign and value: spring2024
  • Save the post and view frontend
  • Right-click form and "Inspect Element" to verify hidden inputs are present

Screenshots or screencast

Screenshot 2025-07-14 at 4 23 11 PM Screenshot 2025-07-14 at 4 23 48 PM

@github-actions
Copy link
Copy Markdown

Warning: Type of PR label mismatch

To merge this PR, it requires exactly 1 label indicating the type of PR. Other labels are optional and not being checked here.

  • Type-related labels to choose from: [Type] Automated Testing, [Type] Breaking Change, [Type] Bug, [Type] Build Tooling, [Type] Code Quality, [Type] Copy, [Type] Developer Documentation, [Type] Enhancement, [Type] Experimental, [Type] Feature, [Type] New API, [Type] Task, [Type] Technical Prototype, [Type] Performance, [Type] Project Management, [Type] Regression, [Type] Security, [Type] WP Core Ticket, Backport from WordPress Core, Gutenberg Plugin.
  • Labels found: .

Read more about Type labels in Gutenberg. Don't worry if you don't have the required permissions to add labels; the PR reviewer should be able to help with the task.

@github-actions
Copy link
Copy Markdown

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 props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: dhananjaykuber <dhananjaykuber@git.wordpress.org>
Co-authored-by: bradhogan <bradley2083@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@t-hamano t-hamano added [Type] Enhancement A suggestion for improvement. [Block] Form (experimental) Affects the form block labels Jul 14, 2025
@SirLouen
Copy link
Copy Markdown
Member

Closing this as #74131 fixes this more in line with the current implementation.

@SirLouen SirLouen closed this Dec 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Block] Form (experimental) Affects the form block [Type] Enhancement A suggestion for improvement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Experimental form block: add hidden field option

3 participants