Tell us what you are trying to do?
I am trying display a pulldown menu to choose State and County on my post(restricted business listing) creation form.
State and County are already connected with the post with relationship.
I followed the post instruction by Yang. But my final page shows "No Items found."
Honestly, I didn't understand his direct step3. So I just followed without me understanding what I am doing, So, I don't know how to fix them.
Is there any documentation that you are following?
https://toolset.com/forums/topic/how-to-add-relationships-on-post-form/
Is there a similar example that we can see?
What is the link to your site?
this is the current a new post creation form
It needs a customer role account to see a form.
This is the result page the view(screenshot) is embedded.
Hello,
Please provide your test site credentials in below private message box, I can setup a demo in your website according to previous thread:
https://toolset.com/forums/topic/how-to-add-relationships-on-post-form/#post-1578383
I have done below modifications in your website:
1) Edit the post view
in section "Search and Pagination", add a relationship file, see screenshot state-conty.JPG
Test it in front-end:
I can see it works fine, and I can filter the results by parent state posts,
2) Click link "Create new child public-listing post", for example:
you are displaying a post form:
You are not follow our document to setup the relationship filed in above post form
You need to follow our document to setup above post form and relationship field:
https://toolset.com/documentation/post-relationships/selecting-parent-posts-using-forms-create-child-items/
And your website is abnormal, I don't save button when editing/creating a post form, so I did not change above post form in your website. please check it, if you need I to create the form, please backup your website, I need to deactivate plugins/theme in your website.
Hello,
The way you describe is little difficult for me to understand. But I think I am getting things together.
I modified the test form you made
So. Users can start this page to go to actual form next.
There are few questions.
1)Is it possible to hide all list of county until the user choose the state. So this can create steps?
2) how can I display the list of county in a certain order (e.g. alphabetical). I don't know what order the list are currently displayed.
3) After select a county, it goes to the form. To avoid mistakes, I would like to limit the form so users cannot change selected county. I currently set readonly="true"(it sill pass the value when user submit the form right?) but when I do this, I cannot show the value so users cannot see if they have chosen the right county or not. Is there anyway to display chosen County and State based on the parameter?
Thanks!
Q1) Is it possible to hide all list of county until the user choose the state. So this can create steps?
You can create two pages, one page(PAGE A) display only the search form, the another page (PAGE B), so in PAGE A, your users can only see the search form, after he submit the form, redirect him to PAGE B, he will be able to see both the search form + search result, more help:
https://toolset.com/course-lesson/creating-a-custom-search/
Q2) how can I display the list of county in a certain order (e.g. alphabetical). I don't know what order the list are currently displayed.
You can edit the post view:
In section "Ordering", use option: Post title + Ascending
Q3) No, your method will disable the parent selector, after submit the child post form, it won't be able to connect to county post, you can follow the document I mentioned above to setup CSS codes to hide the county select field:
https://toolset.com/documentation/post-relationships/selecting-parent-posts-using-forms-create-child-items/#creating-forms-when-a-parent-post-is-preselected
section "Creating forms when a parent post is preselected", screenshot:
https://toolset.com/wp-content/uploads/2019/02/toolset-form-hide-parent-selector-field-1.png
Hello Yang,
1) How can I create this flow? I am guessing you can duplicate the same view and delete search result part for Page A and show the original view on Page B but I don't know how to make the submit button to trigger jump to Page B and how to pass the state selection to Page B.
And How do I let Page B receive parameter from Page A when users hit select button.
I read the instruction but it doesn't explain.
2) With your information, I was able to set it . Thank you.
3)If readonly technique doesn't work. I go back to use .hidden css method you original recommended. However, I still want to show what county the user choose from the previous page. How do I display that? I was thinking like "your listing goes to XXXX county in YYYY state" or something. But I need both County selection data and its related state information.
How do I pull the information from Pamater ID and display?
Q1) There is a simple workaround with some PHP codes, I have done below modifications in your website:
1) Create a new snippet "display_empty_on_load" here:
add_filter( 'wpv_filter_query', function( $view_args, $view_settings, $view_id ){
if ( in_array( $view_id, array( 9529 ) ) ) { // Edit for View IDs
if(isset($_GET['wpv-relationship-filter']) && $_GET['wpv-relationship-filter'] != ''){
return $view_args;
}
$view_args['post__in'] = array(0);
}
return $view_args;
}, 99, 3 );
It will check if there isn't URL parameter "wpv-relationship-filter", then display none result
Test it in front-end, it works fine:
You can change the text "No items found" here:
section "Loop Editor"
More help:
https://toolset.com/documentation/programmer-reference/views-filters/#wpv_filter_query
Q3) You can use [wpv-search-term] to get URL parameter value, then get related parent post information, for example, edit the post form:
Your listing County [wpv-post-title item='[wpv-search-term param="parent_county_id"]']
Above shortcode will retrieve county post title of URL parameter "parent_county_id"
Test it in front-end:
More help:
hidden link
Hello Yang,
Thank you for your help.
My flow is so much better now.
regarding Q3, is it possible to show the state(which is a parent of County)? Basically show the name of the post title of Parent of parameter's ID value.
Q4) You mentioned earlier
"And your website is abnormal, I don't save button when editing/creating a post form, so I did not change above post form in your website. please check it, if you need I to create the form, please backup your website, I need to deactivate plugins/theme in your website."
Which part were you talking about? If the problem still exist, I would like to address it. Please share the information in detail.
Thank you.
Q3) Yes, it is possible, I have done below modifications in your website:
1) Create a new content template "County information":
With below codes:
County: [wpv-post-title]
State: [wpv-post-title item="@state-county.parent"]
2) Display above content template in the Toolset form:
[wpv-post-body view_template="county-information" item='[wpv-search-term param="parent_county_id"]']
Test it in front-end:
It works fine.
Q4) I wasn't able to see the "Save Form" button when edit the post form, I have tested it again, do not see the problem any more.
My issue is resolved now. Thank you!
Hello I would like to hide my website name from this post. The name shows up on the screenshot. It is possbile to change that?