Skip to content

Commit 7973b13

Browse files
committed
View config: Add the showPlaceholderIfEmpty option to the panel form layout schema.
Adds a boolean `showPlaceholderIfEmpty` property to the panel form layout in the view config REST schema. When true, the panel summary shows the field's `placeholder` instead of its `render` output when the value is empty (`undefined`, `null`, or an empty string). It is `false` by default, so existing forms are unchanged. Schema only, no behavior changes on the server. Ports the changes from the Gutenberg plugin. See WordPress/gutenberg#82527. Props ntsekouras, oandregal. Part of #65981. git-svn-id: https://develop.svn.wordpress.org/trunk@63530 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 57fe7db commit 7973b13

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

‎src/wp-includes/rest-api/endpoints/class-wp-rest-view-config-controller.php‎

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -631,6 +631,7 @@ protected function get_grid_layout_schema() {
631631
* matching the TypeScript Layout union in dataviews/src/types/dataform.ts.
632632
*
633633
* @since 7.1.0
634+
* @since 7.2.0 Added the `showPlaceholderIfEmpty` property to the panel layout.
634635
*
635636
* @return array Schema for a form layout object.
636637
*/
@@ -655,15 +656,15 @@ protected function get_form_layout_schema() {
655656
array(
656657
'type' => 'object',
657658
'properties' => array(
658-
'type' => array(
659+
'type' => array(
659660
'type' => 'string',
660661
'enum' => array( 'panel' ),
661662
),
662-
'labelPosition' => array(
663+
'labelPosition' => array(
663664
'type' => 'string',
664665
'enum' => array( 'top', 'side', 'none' ),
665666
),
666-
'openAs' => array(
667+
'openAs' => array(
667668
'oneOf' => array(
668669
array(
669670
'type' => 'string',
@@ -686,7 +687,7 @@ protected function get_form_layout_schema() {
686687
),
687688
),
688689
),
689-
'summary' => array(
690+
'summary' => array(
690691
'oneOf' => array(
691692
array( 'type' => 'string' ),
692693
array(
@@ -697,10 +698,13 @@ protected function get_form_layout_schema() {
697698
),
698699
),
699700
),
700-
'editVisibility' => array(
701+
'editVisibility' => array(
701702
'type' => 'string',
702703
'enum' => array( 'always', 'on-hover' ),
703704
),
705+
'showPlaceholderIfEmpty' => array(
706+
'type' => 'boolean',
707+
),
704708
),
705709
),
706710
// CardLayout.

0 commit comments

Comments
 (0)