acf-extended / ACF-Extended

🚀 All-in-one enhancement suite that improves WordPress & Advanced Custom Fields
https://www.acf-extended.com
238 stars 27 forks source link

Incorrect REST-Schema for Taxonomy Terms field #108

Closed jwdsign closed 1 year ago

jwdsign commented 1 year ago

Describe the bug Trying to update a Taxonomy Terms field via REST API v2. The values are saved as an array, but the REST-Controller expects type "string, null".

To Reproduce

Expected behavior Expected REST-Schema: ['string', 'array', 'null'];

Screenshots Error Message:

WordPress & ACF WordPress version: 6.0.2 ACF Pro version: 6.0.2 ACF add-ons: ACFE

acf-extended commented 1 year ago

Hello,

Thanks for the feedback, and sorry for the late answer!

Since ACF now provides an builtin method for Field Types REST API, I can easily provide the correct schema for this field. I'm adding it on my todo lsit for the next patch!

In the meantime, you should be able to fix by yourself using the acf/rest/get_field_schema filter. Usage example:

add_filter('acf/rest/get_field_schema/type=acfe_taxonomy_terms', 'my_taxonomy_terms_schema', 10, 2);
function my_taxonomy_terms_schema($schema, $field){
    $schema['type'] = array('string', 'array', 'null');
    return $schema;
}

Hope it helps!

Have a nice day!

Regards.

acf-extended commented 1 year ago

Hello,

Just a heads up to let you know that this issue has been fixed in the latest patch.

Have a nice day!

Regards.