Hi,
I am trying to dynamically populate a Message field based on another field in a Repeater.
But I always get white screen with my code, the_row(): is added.
The debug info says
PHP Fatal error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 20480 bytes) in /home/xxxx/webapps/xxx/wp-includes/class-wp-list-util.php on line 134
This works:
function cban_shortcode_disable_field($field) {
$field['disabled'] = false;
//$field['readonly'] = true;
$field['message'] = 'ALMA';
print_r($field);
return $field;
}
add_filter('acf/load_field/name=canb_shortcode', 'cban_shortcode_disable_field',20,1);
But if I try to load the message dynamically I got white screen:
add_filter('acf/load_field/name=canb_shortcode', 'canb_shortcode_load_field');
function canb_shortcode_load_field($field){
// if has rows
if( have_rows('canb_notification_bars', 'option') ) :
// while has rows
while( have_rows('canb_notification_bars', 'option') ) : the_row();
/* Get the name from the Notification bar name field */
$canb_name = get_sub_field('canb_notification_bar_name','option');
$canb_name = sanitize_title_with_dashes( $canb_name );
$field['message'] = $canb_name;
endwhile;
endif;
return $field;
}
Can someone point me in the right direction?
I have tried to use Example 2 from this page:
https://www.advancedcustomfields.com/resources/dynamically-populate-a-select-fields-choices/
I want to create a small plugin and in the message I would like to display a shortcode variable which the user can use to embed the notification bar.
Thanks.
Regards,
Peter.