Skip Navigation

[Resolved] Split: Custom display in Forms

This support ticket is created 6 years, 5 months ago. 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
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

This topic contains 6 replies, has 2 voices.

Last updated by Nigel 6 years, 4 months ago.

Assisted by: Nigel.

Author
Posts
#917350

I created the Custom Post Type "Veranstaltungen" with some Custom Posts, for example "Testveranstaltung" and "Testveranstaltung 2".
Right below in the CPT (for example "Testveranstaltung") you see a custom field group "Anmeldeformular". The "Anmeldeformular" should
be a Toolset form and that form should consists of two parts. One part in the form should always be visible (the address of the customer for example). The other part
are form fields, that should only be visible in the form, if the team member in the backend clicks yes ("Ja") from the Custom field group "Anmeldeformular". Is this possible
with conditinoal output in the Toolset form? The form should be right under the event description. So I guess that this is also in the Toolset layout?
Another thing will be the integration of a login option, where the user can register and set up his address. Than, if the user is registered with his address, it should be possible,
that the users address will be adopted in the toolset form "Anmeldeformular". Is this also possible?

#917849

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi Thorsten

Anmeldeformular is not a custom field group, it is a repeatable field group, meaning that for each veranstaltung post you can add multiple instances of this group of fields.

(A simple example of when you would use these would be if you wanted to add contacts to a post and for each contact your recorded their name, phone, and email. So you would add a repeatable field group for contacts to the post with the group containing name, phone and email fields. One post might only need one contact (so one name, one email, one phone), while another might need four contacts (so four names, four emails, four phones).)

Is that what you intended? Will there be multiple groups of "anmeldeformular" for individual posts?

Because you can assign multiple custom field groups to the same post type, so that each one appears in its own meta box on the post edit screen.

Right now you have a Veranstaltungs-Details field group containing various fields, which also contains the "Anmeldungformular" repeatable group of fields.

If you don't intend for this to be a repeatable group, you should instead create a separate Custom Field Group for these fields which you also assign to the veranstaltung post type.

When you talk about conditionally displaying this field group based upon the user clicking "Ja", are you talking about in the back-end or using a front-end Form?

For the back-end you could show or hide the whole "Anmeldungformular" field group based upon the choice of a field from the "Veranstaltungs-Details" group. Assuming you move the Anmeldungformular fields into their own group, in the where to use this Field Group settings, as well as assigning it to the required post type, there is a "Data-dependant" tab you can use to add conditional display rules based upon the selection in other fields.

That is described here: https://toolset.com/documentation/user-guides/types-custom-fields-conditional-display/

You can do something similar in front-end Forms.

https://toolset.com/documentation/user-guides/cred-conditional-display-engine/

Let me know if that makes sense (and we are talking about the back end or front end) before I turn to the last point.

#918770
AnmeldeformularBirkenhof.jpg

Hi Nigel,
my intention with the repeatable field group "Anmeldeformular" is the following. I desribe the whole workflow for this:

1. The User sees the overview of all events (thats, as you know, my created view): hidden link

2. The User clicks on one of the events links to see an overview of the related single event. This contains the event details (for example an christian event-weekend where the people of this event are talking about a specific topic from the bible etc.).

3. Below the event details there should be a registration form, (in German called "Anmeldeformular" - I think it is a Toolset-frontend-form) where the user puts in two different kinds of data. The first kind of data is a must have for every event. These are the following data:
- Name of the Event (Dropdown-list, which contains the different kinds if christian events - please see attached screenshot)
- Booking-Number of the event (a four-digit number, as you can also see in the attached screen)
- First Name
- Last Name
- Phone Number
- E-Mail
- and some other things (like if he has a voucher for the event etc.)

The second kind of data, the front-end-user has to put in into the front-end-form varies from event to event. These are the data, which I created as the repeatable field group "Anmeldeformular" in the backend, where the team member of "Birkenhof" can choose via the radio buttons "Yes" or "No" if those fields are required for the front-end-form. These data are for example:
- bed linen for 2,50 Euros
- Towel-Set for 2,50 Euros
- We need a child bed
- What kind of instrument are you playing (for a music-christian-event-weekend)
- I would like to sleep in the room with person x
etc.

So my intention for step 3 is, to create a front-end-form, which contains the "Always"-fields (the first kind of data) and the "Varies"-fields (the second kind of data). For the second-kind-data I created the repeatable field group "Anmeldeformular" in the backend. Depending on the value "Yes" or "No", I want to display these fields via conditinal output. If the team member clicked for example "Towel-Set for 2,50 Euros" as "Yes" in the backend, there should appear for example a lable with the text "Towel-Set for 2,50 Euros" with a checkbox in the front-end-form.
Is this possible?

PS: In the attached screenshot you can see the current (old) workflow. For each event, the user has to download the Registration Form as a PDF-File, fill it out and send it via E-Mail to the team staff of "Birkenhof Müden".

#919263

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Screen Shot 2018-06-29 at 12.08.06.png

Hi Thorsten

I set up a test locally to double-check it worked as I expected, and achieved what you want. Let me describe briefly what I did.

I created an Event post type.
I created a Register for event post type (because forms publish posts, this is the post type the form will publish).
My register for event post type has a field group containing common fields, and also some fields which will be conditionally shown according to the event settings. Specifically, I have a "towel" checkbox and a "bedlinen" checkbox, so that when registering for an event you can choose if you want these.
I then created a field group for events themselves which includes radio fields for "offer towel" and "offer bedlinen" (see screenshot for example).

I auto-generated the form for register for events, which included the towel and bedlinen fields.

I then edited the form to wrap these two fields in conditional statements to only show them if the corresponding offer-towel and offer-bedlinen fields from the event were set to "yes", like so:

[wpv-conditional if="( $(wpcf-offer-towel) eq 'yes' )"]
	<div class="form-group">
		[cred_field field='towel' value='' urlparam='' output='bootstrap']
	</div>
[/wpv-conditional]

[wpv-conditional if="( $(wpcf-offer-bedlinen) eq 'yes' )"]	<div class="form-group">
		[cred_field field='bedlinen' value='' urlparam='' output='bootstrap']
	</div>
[/wpv-conditional]

I then inserted this form into the template for displaying single events.

So those conditional shortcodes work because the context for the conditional shortcodes are current post object, which is the event being displayed that the form is added to.

#920815

Hi Nigel,
I created a post-form yesterday (Toolset->Create post-form) and I inserted the shortcode into the event-page (hidden link). For the firstname and lastname, E-Mail etc. I took the generic fields. The radio buttons you see in the form are the ones from the CPT "Veranstaltungen" (events) which includes the event details and a repeatable field group "Anmeldeformular" with the fields, that will be includes as if-conditions. For the E-Mail notification to the team maber after a customer filled out the form, can I input the generic form fields (first name, last name etc.) as well as the fields from the repeatable field group as well?

Also, today the client came around with some additional features/changes. AS you can see in the original post (https://toolset.com/forums/topic/display-a-view-or-template/#post-920266) we had to split these topics. The third topic is now the registration/login feature. The customer should have the opportunity to login (register) with the following features:
- Register with his data (first name, last name, e-mail, address etc.)
- Ability to see a list of all the events for which he registered for (from the form https://toolset.com/forums/topic/display-a-view-or-template/#post-920266)
- Ability to autofill the form for an event ( for example https://toolset.com/forums/topic/display-a-view-or-template/#post-920266) with his address-data
- Ability to change/edit the his address data
- Ability to delete events for which he is registered
- Automatically change the password for the user (if he forgot his password or wants to change it).

Is this all doable with Toolset? If one or some of these features is not doable, please let me know.

I think for this feature I have to do a lot of work (relationships / maybe another CPT / Usage of Toolset Access-Plugin etc). It would be very great if you could help me with this topic a little bit.
Thanks
Thorsten

#920916

In addition to my last post, I tried something with toolset forms. For the fields, that should always been visible in the event-registration form (for example https://toolset.com/forums/topic/display-a-view-or-template/#post-920266), I wanted to use the generic fields for first name, last name etc. because. Or is it better to create also custom fields for these kind of form fields? How can I change the date format (for example I want to have the format d.m.y) for a field from type date? I saw a thread, where Luo said, that this can be change in Toolset->Settings->General, but there isn't such an option (https://toolset.com/forums/topic/cred-datepicker-default-format/). Also is there a way to validate a zip-code, that it has 5 digit's? Do I have to use Hooks for that (https://toolset.com/documentation/programmer-reference/cred-api/#cred_form_validate)? If yes, do I have to put the hooks into the functions.php?
Thanks a lot
Thorsten

#921289

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi Thorsten

When you want to include fields in the notification message you need to specify the post id, like so:

[wpv-post-link id="%%POST_ID%%"]

Generic fields are not normally saved and so are not available in notification emails. (It might work if you use "persist":1 to save the generic field to the database alongside the post and specify the post ID in the same way, but to be honest the only way to know is to try: it will either work or not.)

The intention with generic fields is that they are disposable. Typically you would include some generic field(s) in a form, and then use an API hook such as cred_save_data to do something with those generic fields, such as update another field value. If you want to save such fields along with the submitted post, you would normally add them to a custom field group and include them in the form (when they will also be available in notifications when specifying the id as described above).

As for repeatable field group fields, well, to add repeatable field groups with front-end Forms means adding something like a "child" form for each instance of a repeating group which publishes a special rfg post that is linked to the original post to which the repeatable field group belongs. If you create a separate notification for the child post where the repeatable field group is created then you should be able to use such fields in the notification. If the notification is on the "parent" form then, no, the fields from the repeatable field group would not be available.

Regarding whether you can use Toolset for registering users etc., yes, and there is nothing in your list that I see as problematic. You can read about the basics of registration forms here: https://toolset.com/documentation/user-guides/cred-user-forms/ and if you look at that specific section of the training course you should get a clear understanding of how to do it.

If you have a Types date field you can change the format of how the date is displayed when you insert the field into a template, for example, which should be fairly clear from the UI if you insert the date field using the Fields and Views button.

Validation would be done using the cred_form_validate hook, yes, you would need to write the code (there are examples in that documentation) and add the PHP to your child theme's functions.php file.

I think if you need more detailed help on any of this you should open a new thread. I'm just about to start a week's vacation and am finishing up with my queue now.