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
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
it worked in a way. But the value returned was an ID instead of the name of the condo.
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.
Okay great, let me know if you have additional questions about that.