bobbingwide / field-block-for-acf-pro

Field block for ACF PRO
https://www.oik-plugins.com/oik-plugins/field-block-for-acf-pro/
GNU General Public License v2.0
3 stars 0 forks source link

Checkbox rendering not working after cloning #13

Open bobbingwide opened 1 year ago

bobbingwide commented 1 year ago

Detected after cloning content from s.b/oikcom, the logic to render the checkbox field, which uses the rendering for select, doesn't produce the expected results. We see the following Notice

Notice: Undefined index: a:1:{i:0;s:3:”red”;} 
in /home/customer/www/oik-plugins.co.uk/public_html/wp-content/plugins/acf-field-block/includes/class-acf-field-block-renderer.php 
on line 446

phpMyAdmin shows the values being stored as below.

meta_id post_id meta_key meta_value
393844 49098 checkbox a:1:{i:0;s:3:"red";}
393892 49098 select red

In actual fact, updating the field in the ACF metabox didn't appear to survive the round trip.

image

bobbingwide commented 1 year ago

In the servers the post meta value showed that the field had been serialized twice. This is the output when the checkboxes selected are red and amber and the meta data has been cloned.

s:36:"a:2:{i:0;s:3:"red";i:1;s:5:"amber";}";

the value should be

a:2:{i:0;s:3:"red";i:1;s:5:"amber";} 
bobbingwide commented 1 year ago

In actual fact, updating the field in the ACF metabox didn't appear to survive the round trip.

This red herring was a side effect of having the Checkbox field in two field groups with the field having the same name due to it being part of a clone field type. When editing the post meta you have to edit the last of the fields with the same key. This is a known feechur of ACF.