Skip to content

Meta boxes: server side validation with add_settings_error isn't possible #3964

@ghost

Description

Issue Overview

A lot of existing meta boxes, especially in enterprise environments, rely on server side validation / sanitation, including meaningful feedback to the user.

This fails in Gutenberg currently.

Steps to Reproduce (for bugs)

  1. Setup validation as in https://tommcfarlin.com/post-meta-data-error-messages/ , this requires a CPT 'Location' and a meta box with a single text field.

  2. Create a new location, fill in data and save it.

  3. API Call will fail with an error "Call to undefined function add_settings_error()", which is used in the example

  4. Replace add_settings_error() with a simple string to continue testing.
    https://gist.github.com/wsydney76/0dd717fd061908d8037d29ce12569b86

  5. Enter a value and save.

  6. Then leave the text field blank and save. "Post saved" indicates ok, no error messages shown, the field is still blank.

  7. Reload. The old field value is still present.

  8. Enter content like 'with tags and save. Tags will be stripped server side, but that is not reflected in the editor. Only a reload shows the altered content.

Gutenberg 1.9

Expected Behavior

The user has to get information about the data being rejected or changed server side. After a "successful" update the content in the editor must not differ from the content in the database.

Current Behavior

If it works at all, the users workflow is broken, potentially resulting in invalid data.

Possible Solution

Documentation is needed:

  • Which kind of implementations of server side validation breaks in Gutenberg?
  • How can it be changed to work in Gutenberg?

Metadata

Metadata

Labels

Backwards CompatibilityIssues or PRs that impact backwards compatabilityNeeds Technical FeedbackNeeds testing from a developer perspective.[Feature] Meta BoxesA draggable box shown on the post editing screen[Priority] LowUsed to indicate that the issue at hand isn't a top priority to address and can be handled later[Type] Developer DocumentationDocumentation for developers[Type] Plugin InteroperabilityIncompatibilities between a specific plugin and the block editor. Close with workaround notes.

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions