Home › Forums › Add-ons › Options Page › I am using load_field but not load correctly
Hello:
I face some problem need some help!!!
I am using load_field to put values and labels in a checkbox from a repeater in a option page. The structure is shown in the attached image.
https://drive.google.com/file/d/1AHsSP5OTjVFPiUhbz8g-ket7u2rFf1dq/view?usp=sharing
It was OK when I made first version. I added two row of data in repeater in option page. The choices of checkbox show correctly. There are two choices there.
I add one more image field in the repeater. Change the div structure for some effect.
The code is changed div structure in the label of checkbox but doesn’t add the url of the one more image.
It were only two choices in my first version. I add more row of data in the repeater in the option page.
The choices of checkbox still remain two choices.
Here is the code I use for load data from option page
function my_acf_load_field02( $field ) {
$field['choices'] = array();
//check Check rows exists
if( have_rows('repeatercheck', 'forcheck') ){
while( have_rows('repeatercheck', 'forcheck') ) {
the_row();
$parent_text = get_sub_field('text_check');
$parent_image = get_sub_field('image_check');
$effect_image = get_sub_field('image_effect');
$field['choices'][$parent_text]='<div class="parent"><div class="div1"><img src="'.$parent_image.'"></div><div class="div2"><img src="'.$effect_image.'" class="img2"></div></div>';
}
}
return $field;
}
// Apply to fields named "checktest".
add_filter('acf/load_field/name=checktest', 'my_acf_load_field02');
So I have two problem…
1. The DIV structure is changed but the image url doesn’t uploaded to choice of checkbox. The image_effect not showing in the label of choice.
2. The number for choice of checkbox doesn’t change after I add more data of row in the repeater in option page.
Please help. I don’t know where are wrong.
Thank you!!!!
using
Advanced Custom Fields PRO 5.9.4
Advanced Custom Fields: Extended PRO 0.8.7.6
I think I found what is wrong.
I change the post ID to “option”. I didn’t change back to “forcheck”.
How silly I am…
You must be logged in to reply to this topic.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.