Support

Account

Forum Replies Created

  • I’m also getting this on 5.7.11 and 5.7.12. Calling the function get_field() just returns a serialised array on draft previews.

  • Amazing, thanks. I added in a little extra code as I’m using a unique ID for the questions (in case they change the question text):

    $question = get_post_meta($post_id, $repeater.'_'.$i.'_'.$subfield, true);
    $uid = get_post_meta($post_id, $repeater.'_'.$i.'_'.'uid', true);
    $this->choices[$uid] = $question;

    Thanks again! Really appreciate you taking the time to look at this.

  • Thanks for that! Looks very promising.

    I’m getting an Illegal offset type error on the line $this->choices[$question] = $question;

  • Yeah, sorry, I wasn’t that clear – “dependency” is a child of the “questions” repeater.

  • This reply has been marked as private.
  • I created a separate field “dependency2” that wasn’t within the repeater and it seems to work fine. Something in the repeater side of things must be causing the issue. I guess it doesn’t like me calling to the parent field from a sub-field filter (since “dependency” is a sub-field of “questions”).

    Maybe I’ll just have to store the dependencies as a separate set of fields…

    Thanks for all your help on this by the way! 🙂

  • There aren’t any other filters set up, just this one. I’ve only just installed WP and ACF Pro so there’s hardly any code in the functions.php file at all.

    Could it be because it’s within a repeater field?

  • echo '<pre>'; print_r($field); echo '</pre>'; seems to run a bunch of times, out putting the same array, maybe 50+ times, but nothing from echo '<pre>'; print_r(get_field('questions', $post->ID); echo '</pre>';.

    It then doesn’t render anything after (so none of the other sub-fields). This is the array it’s spitting out for $field:

    Array
    (
        [ID] => 15
        [key] => field_56f0735c7223d
        [label] => Dependency
        [name] => dependency
        [type] => select
        [value] => 
        [required] => 0
        [id] => 
        [class] => 
        [conditional_logic] => 0
        [parent] => 6
    )

    It seems like it’s the get_field() function that stops anything further from running.

  • Hi John,

    Yes, so once the user has saved a questionnaire they’re then able to edit the list of questions to add dependencies between questions.

    I added if(!isset($_GET['post'])) return array(); so that the code wouldn’t try running if the post didn’t have an ID (ie. when it’s a new post – since then there wouldn’t be any custom fields to find, since the post would have never been saved).

    Also, to elaborate on what happens, as soon the edit page gets to the repeater field containing the select the code breaks and no more PHP appears to be processed. There are no errors in the log, however.

Viewing 9 posts - 1 through 9 (of 9 total)