Skip Navigation

[Resolved] How to make the repeatable fields group on a form default to the parent CPT

This thread is resolved. Here is a description of the problem and solution.

Problem: I have a Form that creates Job posts. That form is set to redirect to another page that contains another Form that creates RFGs for that Job post. I would like to make sure these RFGs are automatically associated with the correct Job post.

Solution: You'll have to use a bit of custom code to add a URL parameter to the first Form's redirect.

add_filter('cred_success_redirect', 'custom_redirect_job_rfg',10,3);
function custom_redirect_job_rfg($url, $post_id, $form_data)
{
  $forms = array( 94 );
  if ( in_array( $form_data['id'], $forms ) ) {
    return $url . '?jobid=' . $post_id;
  }
  return $url;
}

Then in the Form that creates RFGs, set the Job field default value using the 'jobid' URL parameter. Use CSS to hide this field if necessary.

The new RFG Form must not use AJAX if you want to continue to display the Form after submission and keep the Job selected.

This support ticket is created 4 years, 6 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

Author
Posts
#1331787

Aha - it's a known issue: https://toolset.com/errata/parent-post-selector-in-a-form-that-creates-a-repeatable-field-group-is-not-being-updated-after-ajax-submission/

So for now, AJAX is not supported in new child post Forms where you want to set the parent with a URL parameter, until we get that issue resolved.

#1331789

ok, sounds good.... I'll keep an eye out for your update... thank YOU!

#1331791

You're quite welcome. If you need assistance with the editing forms, feel free to create a new ticket and we can discuss in more detail.

#1331793

ok, so it will work as long as don't use Ajax... that's ok. I will try working on the edit forms and if needed will create a new ticket for that. Thank YOU! I will mark this resolved.

#1331795

My issue is resolved now. Thank you!

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.