Saltar navegación

[Resuelto] Creating a Front End form with dynamically populating select fields

This support ticket is created hace 4 años, 10 meses. 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.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

Etiquetado: 

Este tema contiene 18 respuestas, tiene 3 mensajes.

Última actualización por Christian Cox hace 4 años, 9 meses.

Asistido por: Christian Cox.

Autor
Mensajes
#1516161
Screenshot 2020-02-19 at 11.33.41.jpg
Screenshot 2020-02-19 at 11.17.34.png

I am trying to create a front-user form that allows our commercial clients to tell us, what various versions they are ordering from us.

The structure of the order is quite complex, there are elements that keep repeating themselves and others that are unique to that order.

So I am looking for a form that 'guides' the front end user to fill in the information in the most convenient way and so he does not have to enter the same information for too many times.

Basically the client tells us, how many versions of a commercial movie he wants to order.

So I have create a CPT called 'Versions' with many custom fields for the different aspects of the version.

I could now create just a simple form with all the fields, but then the client has to repeatedly enter ALL the fields again for each version.

But since some of the fields are keep repeating themselves I would like the user to be able to 'drill down' from the top to the bottom, so he only has to define the main fields only a few times.

Since the main fields are holding information that is unique and will be created by the user when he fills out the form, these fields propably have to be created first and then be used to dynamically populate another form that creates the versions?

I have a feeling this could be achieved with repeatable groups but I am struggling to wrap my head around it, maybe you have similar uses and can guide me in the right direction or to a working example, where users are guided inside a form?

The attached two screenshots show you how we gather the info so far in excel and airtable. Excel really requires us to input (or copy paste) every aspect of a version. Aritable at leasts lets me populate the dropdowns with my own info, but still requires to create an item for every version. Also with filters I could 'summarize' for example by MEDIA or FORMAT

If a form could guide the user through a form: first defining the bigger items and then on defining the smaller things that would be perfect.

Sorry for not being clearer, as I said, I have troubles to wrap my head around this 🙂

Looking forward to your thoughts
Tobi

#1516721

Hi, what if you allow the User to create one Version, then show a table of Versions. In the row for the one existing Version, include a button next to that Version that says something like "Clone this Version". That button opens a Form to create a new Version, but all the fields are prepopulated with the selections from the existing Version. Then the User can add or remove configurations as needed to create a similar Version post. Each Version created would display in that table, and each row would have a button to clone that Version like a template. Is that process what you had in mind, or something more complex?

#1518457

Yep, this is definitely a feature I would like to have for the 'complete version list'- this list would look more or less like an excel list and it would be great to 'clone' the entries. This would be a list that is for our technical personnel.

But I am also looking for a way to create the list in a more 'human readable' way for the client frontend.

If you look at the excel you will see that the first few colums are very hierarchical: I am looking for a way to enter the 'sujet' name first, then add the 'medias' for that 'sujet', then add the 'lengths' for those 'media' items - and so on. From that, the complete 'versions' list (as decribed above should be generated.

I am working on something right now that involves many custom post types connected together. It's going okay, but I am not sure, if I am going overboard with this and if there is not a simpler solution. It would be great if you could have a look at it. If you grant me private status I am happy to share the links.

One thing that would be supergreat when doing it the custom types way would be this: if a client could choose from several options from checkboxes in the frontend and toolset would then create automatically a custom post type for each chosen box. As it stands right now, my user has to create each 'media type' (for example) by filling out a single form.

Looking forward to your thought, especially if the custom post type way is the right way to go.

Thx a lot
Tobias

#1518913

I'll be glad to take a look at some links. All URLs you share in the forum are private, meaning they are obscured from all other Users except support staff. You can share URLs in confidence here without any private fields.

#1519763

Ah cool, I dis not know that. Here‘s the link to the main list. Please keep in mind this is all total work in progress and testing out:
enlace oculto
And then click on the button link: add sujet

Go to the ‚versions‘ section. This is a first working demo. I have a list that is created by defining a sujet first, then defining the media types for the sujets, the durations and languages. It works with custom post types and nested views.

1) is that a god way of doing this?

2) is there a way to create the custom post types for lets say ‚Media types‘ in one go? (Select several checkboxes and all checked boxes create a custom post type?

3) hoe can I automatically create an excel type list of this where each entry shows all the details in each cell and the each version has its own auto-created number?

4) is there another way of automatically create and attach a custom post type to a related cpt without having to go to another page?

Looking forward to your thoughts. Let me know how I can give you backend access so you can gave a closer look.

Thx again
Tobias

#1527189

And then click on the button link: add sujet
Okay I did this, now I can see my test CCTest1 in the Versions list.
Let's take this one step at a time, because I am totally lost here. The next thing you mentioned is something about Media Types. What are Media Types - are these taxonomy terms you want to associate with a Version post, or are Media Types custom post types you want to relate to the Version using post relationships?

If they are custom post types, do these posts already exist, or will the User create new Media Type posts now?

#1527219

Hey Chris, thank you for your patience and sorry, if my explanations were not clear. I might have this all wrong, that's why I need your help 🙂

I have continued to work on this over the weekend and have now tried to structure it a little bit clearer on the test site so you see better what is going on.

My goal is to create two different ways to look at the same list. This list'Versions' shows the various film/media versions of a certain project 'Wintersport'. Each version can have several media types, languages, subtitles etc.

Traditionally, you would enter something like that in an excel sheet like the one I've attached above. But the problem with that is, that the user has to enter many identical elements several times.

That's why I am looking for a simpler way to enter this. You can see my try under: 'Versions - Hierarchical View'

So first you enter the 'Sujet'. That's what you did with 'cctest1' - then you click on 'cctest 1' - this will allow you to add 'media' - which is a custom post type related in a one to many relationship with sujet (cctest 1) - when you have added media - click on media and this will allow you to add the 'durations' for the version, which is again a one-to-many relationship with media type, and so on.

This allows the user to enter information like the 'sujet name' only once and then add more info to that in a hierarchical fashion. The last custom post type in that row is then the custom post type 'version'.

With this custom post type I would like to then create the second way of looking at the versions data which is a classic 'excel type' list. This is what I am demoing on the page under ''Versions - List View' (not finished)

So to take this one step at the time:

- click on your cctest 1 and create several media custom post types, then again click on the created media links and create durations and so on until you have created your first version. This should give you an idea of what I am trying to achieve. The process is still to complicated but it hopefully gives you an idea what I am going for.

Thanks so much
Tobias

#1528909

Okay thanks, I've created one Version and I can see what you mean. The process is complicated because there are many different levels of relationships and many different criteria for a Version. As you add in more nested Views, this page is going to become slow because of the number of nested Queries it has to perform.

2) is there a way to create the custom post types for lets say ‚Media types‘ in one go? (Select several checkboxes and all checked boxes create a custom post type?
You could use a generic checkboxes field instead of the standard post relationship field. Populate the options for these checkboxes with a View of Media Types. Then use custom code with the cred_save_data hook and toolset_connect_posts to create Many-to-many relationships between the post created by the Form and the selected Media Types.

#1528927

Thanks Chris.

1) If I understand you correctly you mean that because of the various levels of relationships this is complicated no matter how I solve it? For the moment I am solving this with an AJAX button, that only loads the list if the user really needs it and click on it. Or do you see a better way of going about this?

2) this sounds great since it would avoid several extra steps in creating the list. do you have any similiar case or link that would guide me how to do this? I am not an experienced coder... 🙂

Thx again! T

#1530845

1) I mean the multiple levels of relationships is complex, and it will require many queries to fetch information about these related posts from the database. This could cause slow response times if you have a large number of posts in the list, many related posts, many custom fields and many taxonomy terms to display. You will need many nested Views to display all this information, and as you add posts and levels of hierarchy these queries will take longer and longer. You may need to add pagination of some kind to keep the lists small.

2) I can show you some examples here on the site. This ticket is similar to what you want to accomplish, and includes some example code and other resource links: https://toolset.com/forums/topic/toolset-forms-many-to-many/#post-1189896

You can see that the solution requires a significant amount of PHP custom code. If you're not familiar with PHP, you will probably need an independent contractor who understands PHP and is familiar with Toolset's APIs.

#1534635

Hey Chris, thx for this link!
https://toolset.com/forums/topic/toolset-forms-many-to-many/#post-1189896

This is almost what I am looking for, the only difference is that I would like to create new entries in the form and then connect them to an existing custom post type. Do you have any link or advice on how to achieve that? Thx!

#1536023

This is almost what I am looking for, the only difference is that I would like to create new entries in the form and then connect them to an existing custom post type.
Let me be sure I understand. This generic field is populated by a View:

[cred_generic_field field='select_teachers' type='checkboxes' class='' urlparam='']
{
"required":0,
"validate_format":0,
"default":[],
"options":[ [wpv-view name="select-teachers-in-studio-form"] ]
}
[/cred_generic_field]        

Are you saying you want to create options for this field in a different Form, or you want to be able to create options for this field in the same Form?

If you want to create options for this field in a different Form, just create a new Form that creates Teacher posts. There's nothing special about it. If you want to create options for this field in the same Form, that's not something you can easily achieve with Forms. You would have to be able to create a new Teacher post somehow, then reload the Form to see that new option appear in the generic field.

#1543261

Hmm, I think I am not making myself clear, sorry. I am looking for a way to create multiple new posts with the same form.

So in the form there would be a field with several check boxes: option A, B and C. If the user clicks on option A & C, the form would automatically create posts A and C and would connect them to the related post.

This would allow me to quickly create a hierarchical list as mentioned above.

As is is now, I have to create each post seperately, here you can see my test:
enlace oculto

Go to 'Versions - Hierarchical View' and click on one of the 'sujets', you'll get to a page similar to this:
enlace oculto;?sujettitleid=new%20sujet

So here instead of a select field I would then create checkboxes and when the user clicks several options and submits the form, toolset would create all the selections as single posts and connect them to the sujet.

#1543877

I understand. You can create whatever new posts you want to create based on the User's selections in the generic checkboxes field. To create a post programmatically, you can use the wp_insert_post function: https://developer.wordpress.org/reference/functions/wp_insert_post/

The wp_insert_post function will return a post ID for the new post it just created. Then you can use that new post ID in Toolset's post relationships API to automatically connect the new post and the current post: https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/#toolset_connect_posts

#1543913

Hey Chris. Thx so mich for replying on a Sunday. Yeah that sounds like what I’m looking for! But it also sounds like quite some php programming work 🙂 before I sink my teeth in: since I am not a coder do you think I should get a contractor right away or can I get away with it with my really minor coding experience? Thx!! T