Skip Navigation

[Résolu] Gravity Forms default value from Toolset custom field in related post

Ce fil est résolu. Voici une description du problème et la solution proposée.

Problem: I have two custom post types connected in a Toolset post relationship. On one of the post templates, I am displaying a form created by Gravity Forms. I would like to set the default value of a field using the value of a Types field from the related post.

Solution: It may be possible to set the value of a custom field from a related post using a Types field shortcode and Gravity Forms dynamic field values and the Gravity Forms shortcode with dynamic attributes.

Relevant Documentation:
https://docs.gravityforms.com/allow-field-to-be-populated-dynamically/
https://docs.gravityforms.com/using-dynamic-population/

This support ticket is created Il y a 3 années et 2 mois. 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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

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 3 réponses, has 2 voix.

Last updated by zeljko-turkaljS Il y a 3 années et 2 mois.

Assisted by: Christian Cox.

Auteur
Publications
#1922025

Hi guys,

I have one problem and can't solve the issue, any help will be appreciated.

I have current showcase site (www.wrightco.net) where we host our demo listing environment for our future clients. After some years we decided to move forward and to upgrade toolset layout and use the toolset relations.

In this current site, on the listing content template we have Gravity form on the right side (for example: hidden link -> hidden link). This Gravity form is using data from the current listing (broker email address) and I'm sending to that email address client request. This broker email field is part of the Listings custom post type layout. Please check this attached screenshot: hidden link. And we can successfully at the end send requests to broker email (hidden link).

In new layout (hidden link), I don't have any more this custom field (broker email) as part of the Listings custom post, but I'm using relations and pulling those informations that way in listings content template. Now, when I want to showcase related broker for that listing, I'm using this shortcode: {!{types field='email' item='@broker-listing.parent'}!}{!{/types}!}. But now, I don't know how to set that custom field in Gravity any more, as gravity doesn't understand this. Here is that page on new development site: hidden link

Can you please help me solve this issue

Thanks

Sasa Vidakovic
Deal Studio

#1922137

Hello, it looks like you are able to display the information using a Toolset Types field shortcode, but you need a way to insert that value in a Gravity Forms element somehow. I'm not really the best source of information about how to use Gravity Forms like this, because I'm not trained in their software and there is no direct integration layer between Toolset and Gravity Forms. If it's possible to use a custom shortcode to insert information in their software, I can help you create a custom shortcode or some other PHP function to retrieve the correct value, but I'm not sure how to implement something like that in their software. Their support team might be able to help you set up something like a custom function or shortcode, then I can help you implement Toolset's API in that custom code.

I did a quick search and found these documents in their site:
https://docs.gravityforms.com/allow-field-to-be-populated-dynamically/
https://docs.gravityforms.com/using-dynamic-population/
It seems that you might be able to use parameters to populate default field values dynamically. If those parameters support 3rd-party shortcodes, you might be able to pass the Types field shortcode into that parameter to set the value dynamically. I'm not really sure, their support team would be able to determine whether or not their shortcode parameter system supports nested third-party shortcodes, like this example:

Test email field shortcode: [types field='email' item='@broker-listing.parent'][/types]<br />
[gravityform id="1" field_values="parameter_name1=[types field='email' item='@broker-listing.parent'][/types]"]

In the example, I have included code to test the email field shortcode is working correctly, then I have included a Gravity Forms shortcode with some parameter called "parameter_name_1". This example should output the email field value, then the Gravity Form. You would then be able to set the default field value using parameter_name_1 as the parameter source.

If the Gravity Forms parameter system accepts third-party shortcodes, this might be a practical solution. Otherwise, we need more information from the Gravity Forms team about how to set a default field value using a PHP function or a custom shortcode.

#1922261

Hi Christian, it works! Thanks

#1922265

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.