Tell us what you are trying to do?
I've created 2 post forms "Quan tâm tin bán" (Interested in Sales) and "Quan tâm tin thuê" (Interested in Rents) for "Tin bán" (For Sales) and "Tin thuê" (For Rent). In the post forms, a guest must choose the post they want. So, are there any ways to select the current post that the guest is on?
Is there any documentation that you are following?
Is there a similar example that we can see?
What is the link to your site?
Hi there,
As the form is using advanced Select2 library to select the post it is not possible to give jQuery code to pre-select the post.
I wonder how you set the form and if it is possible to use a simpler normal HTML select so that I might be able to give you a code to pre-select the post.
Thanks.
Excuse me. I'm not ITer so I don't understand things you're saying. I remember that in the past, someone in Toolset team helped me fix the post form select the current post by default and hide this process in front end. He solved it directly, I didn't understand what he did. I lost that website and am creating again. I know a little about HTML, CSS. Please guide me.
Hi there,
I will be happy to help but I need to know the setup you use.
I'd appreciate it if you could give me the URL/User/Pass of your WordPress dashboard after you make sure that you have a backup of your website.
It is absolutely important that you give us a guarantee that you have a backup so if something happens you will have a point of restore.
Make sure you set the next reply as private.
Please give me the information below:
- What is the link to the Form Edit screen?
- Where did you use the Form? Content Template, Widget, ...
Thanks.
Hi there,
I see the issue, usually when it comes to the default item selection, you should link to the form using a button that adds the proper URL parameter to do the default selection using the method below:
https://toolset.com/course-lesson/selecting-parent-posts-when-using-forms-to-create-child-items/#creating-forms-when-a-parent-post-is-preselected
But for your use-case you directly added the form inside the single post template.
I asked the second tier support about this to see if there can be a solution for that.
Thanks.
Hi Christopher,
Is there any news for my issue?
Best regards.
Hi there,
I have an answer from the second tier support.
You basically need a default value set for the post element in the form.
The post element has a field in the form edit screen to have the default item and Toolset has a shortcode that shows the current post ID called: [wpv-post-id]
By adding that shortcode inside the default field of the post you will have the item preselected.
I did it for the Tin Ban form and you can do the same for the other forms. Please check the screenshot.
Thanks.
Hi Christopher,
I got it. Thank you so much.
By the way, could you please guide me to hide this preselected field? I mean a visitor won't be allowed to know and change it.
Maybe this is the last thing regarding to this issue.
Best regards.
Hi there,
As the select box in question is the first item of the form, it is possible to use the CSS code below to hide it:
#cred_form_573_1_1 > .form-group:first-child {
display: none;
}
I added that to the CSS Editor of the form.
In the CSS code above, 573 is the ID of the form, so you can use the same method for the other forms. For example, another form with the ID of 222 will have the CSS code below:
#cred_form_222_1_1 > .form-group:first-child {
display: none;
}
Thanks.