PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Merge tag bug when using pre render

  1. Hello,

    I've noticed a bug with merge tags - not sure if you are aware or if someone can explain why this is not woking as it should.

    I have a radio field labelled 'Item' with the field id 19

    Usually to ouput this data as merge tags I would simply do this...

    choice text {Item:19}
    choice value {Item:19:value}

    Simples. The above merge tags work.

    But when using pre-render php, for example...

    $products = get_field('item_information',$post->ID);
    $items = array();
    foreach($products as $product)
    	$items[] = array(
    		"text" => $product['order_description'],
    		"value" => $product['price_euro']
    	);
    foreach($form["fields"] as &$field){
        if($field["id"] == 19 ){
            $field["choices"] = $items;
            $field["label"] = get_the_title($post->ID);
        }
    }
    return $form;

    If I then use these merge tags...

    choice text {Item:19}
    choice value {Item:19:value}

    They both output the value. Which is incorrect because the choice text should not the choice value.

    Any ideas why this behaviour happens?

    Thanks
    Josh

    Posted 11 years ago on Thursday April 4, 2013 | Permalink
  2. I'll bring this to the attention of the development team for their feedback.

    Posted 11 years ago on Monday April 8, 2013 | Permalink
  3. Cool thanks Chris.

    Be interesting to see what they say.

    Posted 11 years ago on Monday April 8, 2013 | Permalink
  4. I heard back from the development team.

    You need to use both the "gform_pre_render" and "gform_admin_pre_render" hooks to populate the radio button; the hooks can use the same function. If only the gform_pre_render is used, the form object will not have the new radio button choices and will still be using the default First Choice, Second Choice, etc. behind the scenes. This will cause the merge tags to not be replaced. I tested this out on my system and once I added in the gform_admin_pre_render, went into the admin and saved, my form object had what is needed and could match things up correctly to replace the merge tags.

    Does that help?

    Posted 11 years ago on Wednesday April 10, 2013 | Permalink