Skip Navigation

[Resolved] I created a select field for a CRED Form but can't add into the type after that

This support ticket is created 6 years, 3 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)

This topic contains 4 replies, has 2 voices.

Last updated by Christian Cox 6 years, 3 months ago.

Assisted by: Christian Cox.

Author
Posts
#1136707

Tell us what you are trying to do?
CRED Form - Add listing
For the "enter-condo-name" it is a select generic field using the view: dropdown-list.
Thnis works great, but now I need to add the selected "enter-condo-name" into the listing type under listing-development-name. But it is not working.

Is there any documentation that you are following?
I am looking at teh examples but I can't get it to work.

Is there a similar example that we can see?

What is the link to your site?
hidden link

#1136974

Hi, if you want to capture the value of a generic field and save it, you need to use the Forms API. For example, if you want to store the value of a generic field with the slug 'enter-condo-name', into a Types custom field with the slug "listing-development-name", then you can add this code snippet:

add_action('cred_save_data', 'ts_forms_set_generic_listing_development_name',10,2);
function ts_forms_set_generic_listing_development_name($post_id, $form_data) {
  $forms = array( 12345 );
  if ( in_array( $form_data['id'], $forms ) )
  {
    $condoname = isset($_POST['enter-condo-name']) ? $_POST['enter-condo-name'] : '';
    update_post_meta( $post_id, 'wpcf-listing-development-name', $condoname );
  }
}

Replace 12345 with the numeric ID of this Form. If this isn't working, I'll need to take a closer look to see how your site is configured. More information about the Forms API:
https://toolset.com/documentation/programmer-reference/cred-api/#cred_save_data

#1137355

it worked in a way. But the value returned was an ID instead of the name of the condo.

#1137365

Hi I found out the reason. I was storing the post id, so now I changed it and it is working great. Thank you very much.

#1137557

Okay great, let me know if you have additional questions about that.