Tell us what you are trying to do?
We have a Front-End form that creates a custom post type of an advertisement for items for sale. On the Form, we have required fields asking for email address and phone number. After each of those, we have a radio button question asking yes/no re: displaying the information on the advertisement. We want to collect both pieces of information in case the website owner needs to contact the advertiser, but we want the ad to only display the information the advertiser wants to be publicly available.
Is there any documentation that you are following?
I saw this response from September: https://toolset.com/forums/topic/conditional-display-of-field-in-custom-field-group/
stating that certain fields can't be used as conditionals. The article linked in that response is no longer a valid link.
I've also watched and read this documentation: https://toolset.com/lesson-placement/lesson-placements-1621067-1292451/
Is there a similar example that we can see?
What is the link to your site?
The form isn't published yet, since I haven't gotten this to work.
Hi,
Thank you for contacting us and I'd be happy to assist.
From your message, I understand that you are using Toolset front-end forms to collect Ad post information from users, along with the contact information (email, phone). You'd also like to offer a field to users in this form, where they can select whether they'd like their contact information to be publicly visible or not, on a single Ad page.
If my understanding is correct, the other forum ticket that you referenced is not related, as it is about conditionally showing fields in the WordPress Admin area and not the front-end.
( ref: https://toolset.com/course-lesson/conditionally-display-custom-fields-in-wordpress-backend/ )
To achieve this, you can add a radio type custom field for example "Show publicly?", with two options, "Yes" (value: 1) and "No" (value: 2).
( screenshot: custom-field-settings-example.png )
After that, in your front-end template to show the single Ad page, you can include a conditional block ( ref: https://toolset.com/lesson-placement/lesson-placements-1621067-1292451/ ), with a condition to check for the value "1" (option "Yes").
( screenshot: conditional-block-example.png )
As a result, the contact information fields paced inside this conditional block, will only show when the value for the field "Show publicly?" is set to "Yes".
regards,
Waqar
Your understanding of my problem is exactly correct.
I tried to implement your solution, and ran into three further problems.
(1) My Radio Field options are not the same as the ones in your picture. Specifically, I do not have the "Value to Show" section. Is there a setting somewhere in Toolset that would impact what is show as an option here? (see attached picture)
(2) In the Dashboard, this CPT does not show a button or file for the Content Template. However, I do have one set up which I can access from the Content Template option on the Toolset menu. I don't know if not seeing the Content Template in the Dashboard is a problem or not? (see attached picture)
(3) I do not have the same options in the Conditional Block as you do. (See 3 attached pictures)
I checked to see what installs I have on Toolset and found that I did have some updates released today. I installed those, and am now on the most up-to-date versions I have available. (see attached photo). The available Radio Field and Conditional Block options did not change after the update.
Thanks for writing back and for sharing the screenshots.
You're seeing different options because you're using a generic field in your form.
( your screenshot "1917445-Radio_Button_Options.png" suggests that )
Generic fields in forms are the virtual fields that are not defined/registered with the posts, but can be used, on-the-fly, without saving field values in the database:
https://toolset.com/lesson-placement/lesson-placements-1621521-1620257/
But in this case, you do need to save the user's consent/choice about public visibility with each Ad post, so you'll need to define/register a custom field for that as shown in my screenshot "custom-field-settings-example.png" from the last message:
https://toolset.com/lesson-placement/lesson-placements-1620889-1620037/
Once, you have added a custom field for this, you'll see that it will be available in the form for the Ads post type as well as the conditional block's settings.
If the content template is not showing in the Toolset Dashboard, it could be that it is somehow saved without a title/name.
Please go to that template's editing screen and make sure to save it with a title/name.