Skip to content
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

Pods blocks feature (pods_register_block_type) doesn't work with configs from 'get_args()' #7274

Closed
WPLake opened this issue Mar 8, 2024 · 2 comments

Comments

@WPLake
Copy link

WPLake commented Mar 8, 2024

Description

How to replicate the issue:

  1. Register a new Pods block using the 'pods_register_block_type' function and include field types distinct from text (e.g., date or select). For field settings, use field configs of existing fields obtained from the API
  2. Add the block to some page.
  3. Try to fill out the fields

Current behavior:

Field types other than text are not present in the registered block.

Expected behavior:

All fields passed to the signup function should be present in the block.

Details:

The documentation (https://docs.pods.io/code/blocks-api/) states that "fields in pods_register_block_type() use the same exact field config form as normal Pod fields," and it does not mention any field type restrictions.

1. Getting settings of the existing field

$args = pods_api()->load_field(
			array(
				'pod'  => 'x',
				'name' => 'y',
			)
		)->get_args();
		$args = array_diff_key(
			$args,
			array(
				'object_type'         => '',
				'object_storage_type' => '',
				'id'                  => '',
				'parent'              => '',
				'group'               => '',
				'sister_id'           => '',
			)
		);


2. Signing up the block

Array
(
    [namespace] => my-namespace
    [name] => my-name-123
    [title] => tmp
    [description] =>  My description.
    [category] => My category
    [render_type] => php
)

3. Passing the field configs

Array
(
    [0] => Array
        (
            [name] => text
            [label] => Text
            [description] => 
            [weight] => 0
            [type] => text
            [required] => 0
            [text_allowed_html_tags] => strong em a ul ol li b i
            [text_max_length] => 255
            [repeatable] => 0
            [repeatable_format] => default
            [roles_allowed] => administrator
            [enable_conditional_logic] => 0
            [rest_pick_response] => array
            [rest_pick_depth] => 1
        )

    [1] => Array
        (
            [name] => date_field
            [label] => Date field
            [description] => 
            [weight] => 1
            [type] => date
            [required] => 0
            [date_type] => wp
            [date_format] => mdy
            [date_allow_empty] => 1
            [date_html5] => 0
            [repeatable] => 0
            [repeatable_format] => default
            [roles_allowed] => administrator
            [enable_conditional_logic] => 0
            [rest_pick_response] => array
            [rest_pick_depth] => 1
        )

    [2] => Array
        (
            [name] => select_single
            [label] => Select single
            [description] => 
            [weight] => 4
            [type] => pick
            [pick_object] => custom-simple
            [pick_table] => -- Select One --
            [required] => 0
            [pick_format_type] => single
            [pick_format_single] => dropdown
            [pick_format_multi] => list
            [pick_display_format_multi] => default
            [pick_display_format_separator] => , 
            [pick_allow_add_new] => 1
            [pick_taggable] => 0
            [pick_show_icon] => 1
            [pick_show_edit_link] => 1
            [pick_show_view_link] => 1
            [pick_limit] => 0
            [pick_user_role] => Administrator
            [pick_post_status] => publish
            [pick_post_author] => 0
            [repeatable] => 0
            [repeatable_format] => default
            [roles_allowed] => administrator
            [enable_conditional_logic] => 0
            [rest_pick_response] => array
            [rest_pick_depth] => 1
            [pick_custom] => first|First
second|Second
third|Third
            [old_name] => select
        )

)```

### Version

3.1.4
@WPLake WPLake changed the title Pods blocks feature (pods_register_block_type) doesn't work for most of field types Pods blocks feature (pods_register_block_type) doesn't work with configs from 'get_args()' Mar 8, 2024
@sc0ttkclark
Copy link
Member

Currently only these field types are supported:

  • text
  • paragraph
  • datetime
  • number
  • file
  • color
  • html
  • pick (must provide data array or a callable function)
  • boolean

The reason for the reduced support here is that this was originally developed before we had all of our field types converted for React. As a result, these field types are mapped to the supported field types in Gutenberg at the time.

If we get a good React developer helping on the project again, we can consolidate the form fields handling in our Blocks API to completely map over to our Pods DFV API which powers our normal forms (these are different React APIs at the moment).

@sc0ttkclark sc0ttkclark closed this as not planned Won't fix, can't repro, duplicate, stale Mar 23, 2024
@sc0ttkclark sc0ttkclark self-assigned this Mar 23, 2024
@sc0ttkclark sc0ttkclark added this to the Pods 3.1.5 milestone Mar 23, 2024
@WPLake
Copy link
Author

WPLake commented Mar 23, 2024

@sc0ttkclark Thank you for the clarification. I hope that the upcoming improvement to the WP Blocks API in version 6.5 is just the beginning, and eventually, we'll have a fully developed API.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants