Skip Navigation

[Resolved] Cred form relationship select default value

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
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 2 replies, has 2 voices.

Last updated by TomW5440 4 months, 2 weeks ago.

Assigned support staff: Luo Yang.

Author
Posts
#2424221
agent.png
property.png
entry-agent.png

Tell us what you are trying to do?

I have 3 CPT with 1 to many relationships:

Agent - Property
Agent - Entry
Property - Entry

The agent post displays all properties and entries for the agent.
The property post displays property details
The entry post displays all communication about a property from form user

I've created an 'add new' Entry form which is located on a single property post. I have two relationship selects for @property-entry.parent and @agent-entry.parent and which need a default value for each. This works fine for @property-entry.parent using:

[cred_field field='@property-entry.parent' value='[wpv-post-author]' class='form-control' output='bootstrap' select_text='--- not set ---']

But it doesn't work for @agent-entry.parent. I'm guessing it's because the form is located on a single property post and not agent post so the agent is not a parent? It's more like the grandparent. I tried creating new CF in Property to store agent and then pull that fields data but thats not working either:

[cred_field field='@agent-entry.parent' value='[types field='property-agent'][/types]' class='form-control' output='bootstrap' select_text='--- not set ---']

So I created a generic select as to pull those values and it still not working. I wonder if this is a seperate issue because whether the select was set @agent-entry.parent or something else it never seems to work.

Following on I created a generic text field set as @agent-entry.parent and it did set he default value correctly, however upon submitting it didn't set the relationship between the agent and entry.

So I'm really not sure how to get this relationship select to have a default value based on CF data of the parent property the form is located?

As a complete workaround I wondered if I could lose the relationship agent - entry. Agent already has relationship to property and property to entry. So I went back to single agent template to tried to create a view of entries using a filter to display only those with with same agent name. It looked like this could be achieved with url parameter option as the agent name is in the url but I'm not sure what to enter as url parameter.

So I've kind of hit a brick wall on either option here and was hoping for some guidance please.
Thank you.

#2424447

Luo Yang
Supporter

Languages: English (English ) Chinese (Simplified) (简体中文 )

Timezone: Asia/Hong_Kong (GMT+08:00)

Hello,

In the single property post, you can get it's parent "agent" post ID with shortcode:

[wpv-post-id item="@agent-property.parent"]

More help:
https://toolset.com/documentation/programmer-reference/views/views-shortcodes/item-attribute/

Then use above shortcode as default value, like this:
[cred_field field='@agent-entry.parent' value='[wpv-post-id item="@agent-property.parent"]' class='form-control' output='bootstrap' select_text='--- not set ---']

#2424577

My issue is resolved now. Thank you Luo!