Home › Forums › Bug Reports › Repeater WYSIWYG can't get value
Hi,
Not sure if this worked well before some recent up dates or not, but I’m having an issue with trying to get a WYSIWYG field’s value in a repeater field with use on an options page.
I’ve quad-checked my code and it all seems fine and even done some debugging.. The variable I am trying to assign the value to isn’t even getting filled, but in the backend, when I save the options, its fine and displaying the saved text still.
Thanks.
if ( get_field('do_cf_resume_item_block','option') ) :
echo '<div class="resume-block-container">';
while ( has_sub_field('do_cf_resume_item_block','option') ) :
// Get Vars
$content = get_sub_field('do_cf_resume_item_block_content','option');
$gettitle = get_sub_field('do_cf_resume_item_block_title','option');
$title = do_resume_block_title_display($gettitle);
echo '<div class="resume-block-item">';
echo '<h3>' . $title . '</h3>';
echo '<div class="resume-block-item-content">' . $content . '</div>';
if (empty($contentgo)) echo 'Nothing here.';
echo '</div>';
endwhile;
echo '</div>';
endif;
Thanks.
Hi @synergywp
I see 2 issues with the above code:
1. get_sub_field does not have a second parameter, this may be producing an error and preventing the code from working
2. Your if statement refers to a variable which does not exist (typo)
How are you with debugging? Can you debug your code to find out the variable data?
Hi @Elliot,
Okay, that makes sense about the 2nd parameter and I’m sure that will fix it.
But the If statement… I actually got that code here without thinking about it much:
<?php if(get_field('repeater_field_name')): ?>
From: http://www.advancedcustomfields.com/resources/field-types/repeater/
Oh, I see, you meant the $contentgo if statement.
Yea, i was doing that for testing and had the contentgo var being loaded with something else… i’ve spruced everything up and its still unfortunately not working.
Code as of now:
if ( get_field('do_cf_resume_item_block','option') ) :
echo '<div class="resume-block-container">';
while ( has_sub_field('do_cf_resume_item_block','option') ) :
// Get Vars
$content = get_sub_field('do_cf_resume_item_block_content');
$gettitle = get_sub_field('do_cf_resume_item_block_title');
$title = do_resume_block_title_display($gettitle);
echo '<div class="resume-block-item">';
echo '<h3>' . $title . '</h3>';
echo '<div class="resume-block-item-content">' . $content . '</div>';
if (empty($content)) echo 'Nothing here.';
echo '</div>';
endwhile;
echo '</div>';
endif;
Hi @synergywp
What do you get for:
<?php
echo '<pre>';
print_r(get_field('do_cf_resume_item_block','option'));
echo '</pre>';
die;
?>
I get:
Array
(
[0] => Array
(
[do_cf_resume_item_block_title] => programs
[do_cf_resume_item_block_content] =>
)
[1] => Array
(
[do_cf_resume_item_block_title] => training
[do_cf_resume_item_block_content] =>
)
[2] => Array
(
[do_cf_resume_item_block_title] => OtherTITLE
[do_cf_resume_item_block_content] =>
)
)
There is definitely something being written to the database though. When i leave the page and revisit (the options page in backend), it will have the value there waiting for me.
Wait. I’m sorry, I was wrong and for the double post.
The database is not saving the value. So its nothing at all with my front end code at this point.
Something isn’t saving correctly to the database. When I enter lorem, I save options, leave page, go back to page, the WYSIWYG editor is blank again.
Hi @synergywp
There is a chance that the field_name is too long for ACF to save the value!
Can you try and rename the field name to something shorter?
Hi @elliot,
Yes, that was it. I never realized there was a max character for CF keys!
Fortunately, that’s the only one that extends that long, so I’ll start to use abbreviations when possible. do_cf_res_item_con works I suppose.
Thanks again. Excellent plugin. I’ve purchased 3 of your add ons and use ACF on several projects.
The topic ‘Repeater WYSIWYG can't get value’ is closed to new replies.
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.