Skip Navigation

[Resuelto] Repeater Fields Groups in CRED working?

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

Hoy no hay técnicos de soporte disponibles en el foro Juego de herramientas. Siéntase libre de enviar sus tiques y les daremos trámite tan pronto como estemos disponibles en línea. Gracias por su comprensión.

Sun Mon Tue Wed Thu Fri Sat
- - 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00
- - - - - - -

Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)

Este tema contiene 30 respuestas, tiene 2 mensajes.

Última actualización por Ljuba hace 6 años, 3 meses.

Asistido por: Beda.

Autor
Mensajes
#1072395

I can'g do it now, but I think that for tomorrow I will get form(s) done and if everything will be fine, we can close the ticket, if not, maybe you will find solution(s). So, please wait till tomorrow.

#1072461

1. To get 'parent half' of the form, we ALWAYS first need to use sort of 'trick' to force user to create it.

OK, but can you do that in the backend?
No.
A post, can only be assigned to a Parent, if that parent exists.
If you create a new parent, then you click a button that creates a new parent.

And, that you can do as well with Toolset.
You just need to replicate the exact same in Forms

- Create an "Add Parent Form" (redirects to page to add Child)
- Create an "Add Child Form" (redirects to page with relationship form)
- Create an "Relationship form" (redirects to whatever other page, even in circle you can go)

So, yes, you need more steps to have this, but it is entirely possible to create parent, child and connection, in the front end, with the same logic.

2. I basically first should to 'force' client to submit his personal data (in essence, to 'register him as user') and just after that to let him to choose the rooms.

I understand what you mean, and we are aware of this.
But, to Toolset's credit, many other sites require to you to do exactly what you outline in the above phrase.
And most likely, for similar reasons.
Sometimes you just cannot do everything in one strike.

However, we are of course always trying to enhance this.

Right now, it is possible to streamline this with Forms that redirect, maybe even using AJAX.

3. Is it possible to use 'click' on 'Reserva ahora' like trigger for some kind of automatic generation of 'parent form'?

Theoretically you can add any code, within the Toolset Forms hooks, to any form that either creates or edits posts or users.
NOT relationships
Those forms have no API yet hence, you cannot hook any code.

In another theory, you can simply create a custom HTML button that when clicked calls a PHP script that does some magic, such as inserting a post in another type (although, that is already easily possible with Toolset, I do not really understand why the 3 steps of creating 3 forms are more work, less wanted, than actually creating a massive API that needs maintenance and coding skills - but that is everyone's own point of View 🙂 )

4. The missing repeating feature in those forms is a fact, I cannot change it.

It cannot be done the way you suggest.
It can be done the way I suggest here:
https://toolset.com/forums/topic/repeater-fields-groups-in-cred-working/#post-1070127

But that gives you no drag and drop or even visual reference to the order.
Hence, a custom JS should be created to capture the dragged order as a number and update that field.

You can not loop over "not-existing" items in Views, hence, you cannot create a "add new" feature there in this sense.

Again, you can do that with 100% custom code, by creating a custom GUI that lets you do what you want, it's not yet possible at all in Forms, unfortunately

Of course, the way I outlined is as well not a bad one.
You just redirect to the same form and keep adding RFG's.
A view on top of it, in the same page, can even display the already created RFG's.

I know it is not what you do in the backend but it is what is available right now - future releases will have improvements on this

#1072548

Your post actually placed me in position to figure how I did not notice "the tree due to the forest".

Clients (customers) don't makes the booking of the hotel, rather booking of the rooms (and rooms only belongs to hotel). Moreover, that fact open possibility to limit numbers of repeaters to number of available rooms (irrelevant now). Repeating booking of the room form is actually submission of the new standalone post of room reservation. In other words, parent post for reservations is Rooms (known post - question remain for child post). When user finish it, he just should to be redirected to the rest of the generic fields of Customer CPT.

So, here is situation of Rooms - Customers (will be also > Products - Customers > Services - Customers ...), where Reservas CPT should to be 'intermediate post' for 'many-to-many' relationships (and could be 'cleaned' by expiration if we don't want to keep data of bookings). As Reservas CPT is 'intermediate post' in relation Rooms - Customers, MAIN question is:

a) Can I start to filling new Form with Reservas fields (so, before creation of Customer post)? In other words, can I create 'intermediate post'(s) before 'other side of relation post', or first must be created both 'normal posts?

#1073414

No, an intermediary post type logically is created at the moment you create an actual relation between two other types.

It is not possible to add fields, or relations, to things that do not exist.

That will not change in future either.
It is, how WordPress works.

Yes, you can workaround this by adding steps.
But, you cannot crate things to assign to other things that do not yet exist.

This is not possible

#1073418

Well, I just not sure how that can be done. I created empty test site (so, just this issue is on) and I'm 'playing around' with different CPTs (Rooms, Customers, Bookings) and 'clean' fields and RFGs, with relationships, ... but it cannot act as I need. So, far, I get something eventually acceptable by using RFG of Booking fields (Adults, Childs, Arrival and Departure fields), but that I stuck in Relationship form with Customers Post type (customer should to be created and connected to several 'booking drafts' (of rooms within same hotel). I simply can't find the way to display and connect all currently pending bookings with customer data fields (customer post form). For me appear that I simply must to have previously created customer, to be able to get one (customer) to many (single rooms bookings).

Everything is more complicated as it is not about the post, forms should to be in unassigned Content Template (or eventually in View).

#1073419

I know just that I must to have 3 CPTs (Rooms, Customers and Bookings) with relationships:

> Rooms (one) to Bookings (many)
> Customers (one) to Bookings (many)
> Rooms (many) to Customers (many)

Process schema is

  Room    Room    Room      (type or specific room - two options possible)    
   |       |       |
Booking Booking Booking     (data fields)
       \   |   /
        \  |  /
         \ | /
          \|/
        Customer

But I still can't get it to work.

#1073442

OK, you have a Hotel, a Hotel has Rooms which it rents.
Rooms have features (which mainly reflect in price differences), and they can be booked for an amount of time.
Many Customers can book many rooms, even one customer could book many rooms or many customers just one room.
But, the booking, will be done by one credit card, hence, one Customer.
While the customer can buy many rooms at once, and the same room more than once, he always produces a unique relation between himself, the booking, and the room.

So, I would do this like that:
- A post Type for the Hotel
- A hotel has many rooms, so One To Many relational Room Post Type under Hotel
- A room has many bookings, definitely. Each booking, belongs to ONE room, there is no way around that. If you book 2 rooms, at once, this complicates things, and I suggest here to ask the customer to either make a second booking OR offer him to do it for him (so he does not recon that it's actually 2 bookings he makes)
(In this case, you would not think about Bookings per room but Bookings PER PERSON coming.)
- A booking has ONE payer. ONE Customer. No matter how many people he brings. So, Booking to Customer, is a one to one relation.

We never used a Many To Many relationship yet, and could set up everything with classic post forms which even let you choose a parent and create Childs from posts that exist.

Again: From posts that exist.

So, you need to have existing Hotels, Rooms, and - as soon you want a user to buy whatever - a Customer.
Without that - you cannot create any connection.

So, I assume you will let your clients register. It's not possible elsehow to connect client to product in a Post Connection or similar.
It does not matter however, since the whole approach, does not need neither M2M nor RFG.

The RFG is intended for someone to ENTER data (kind of create data)
When you BOOK something you do not create data.
You CHOOSE data.

So, your bookings should be posts the client submits where he chooses from options.
This Booking post created, is attached to a room.
It can expire.
The room exists before the booking is created.
The Booking post features many Fields like Checkboxes, where you offer the possible booking options
The Booking form can even hold Pictures of the Room, since you are editing/creating a... child of the room, you can display it's parent data.

I think, this requires some changes in the logic.

To allow a customer to book many rooms... the customer just adds new bookings.
Each booking == one room.

I may miss something very crucial, but that is how I would start.
Without even using the RFG and M2M feature which in forms will throw over my workflow.

The RFG I would use to maybe add information ABOUT the rooms (maybe they can have many bathrooms each room)
But not to let the end user actually create a booking.
If you need the user to enter Adults, Childs, Arrival and Departure fields on a booking, for this you do not need RFG.
You can simply add the fields for "nr of adults", "nr of Childs", Arrival Date, Departure Date
Since each booking/room/customer is unique, if the customer wants to extend, or book again, or bring 3 instead of 2 adults, he needs to edit or create a new booking.

That is somewhat how it works elsewhere on famous booking sites

Please let me know if I am wrong with my assumption, but I think, with little less you can achieve much more here.

#1073451
ICH.png

Unfortunately, you are wrong (I would like contrary, as it will solve issue).

1) Initial reason for mistake arise in your presumption that this project is copy of Booking.com (I admit, it looks like), but it is not. Income model is Google, Facebook like model (kind of, not exactly, that's obvious), and not 'commission' model (booking. com) or monthly paid service model (Yelp like). It substantially change everything. Users (business owners) will get ALL SERVICES FREE, what completely exclude any of elements what you listed (image, price, etc...), actually exclude complex forms (idea is > contrary - simple, efficient).

2) Second mistake is assumption how this is BOOKING (no it is not) - it is AVAILABILITY CHECKING, so, customer could (and should to be able) to repeat rooms, service, product, ... (other post types will get same kind of form). That fact imply next characteristics:

a) 'Reservation' data should not to be stored (expiration model could be used - or 'generic fields').
b) Business owners should to confirm availability (briefly - nothing to do with project).
c) Customer data SHOULD BE STORED (VERY IMPORTANT).
d) Credit cards or not, that is also not part of the service (so, visible payments, confused you - that's links to customer payment gateways and not payment to PORTAL - as Booking.com) - so - IRRELEVANT.
e) It is actually, not important either to store relationship Room - Customer (could to expire and 'trash').
f) Customers with higher demands (booking/customers management, will be able to activate third party services forms - to not extend here).

3) Reservation feature is basically business owners PERSONAL FEATURE (as it is on there own website). So, I need (see image) something what is typical for INDIVIDUAL HOTEL WEBSITE and not for 'booking services sites'. On attached image, ONLY SHOULD BE REPLACED field 'Destino' (as it is about hotel chain) to ROOM (like child post). Truth is that displayed form open next forms, but ... I don't need (want) it.

Actually, you can see on image, that if I quit from Room type field, I will be done in 5 minutes (problem solved). Statistics 'push me' to add this repeatable feature (and choice of the room), as 30 -45% of total reservations are for more than one room (safety reason as for single room, many people either do reservations - easy to find).

#1073456

Actually, if I will know how should to be changed function below, to get populated selectable field width available Rooms of the Hotel, I can get what I need in 5 minutes with Formidable Pro.

add_filter('frm_setup_new_fields_vars', 'frm_populate_posts', 20, 2);
add_filter('frm_setup_edit_fields_vars', 'frm_populate_posts', 20, 2); //use this function on edit too
function frm_populate_posts($values, $field){
  if($field->id == 72){ //replace 125 with the ID of the field to populate
    $posts = get_posts( array('post_type' => 'alojamiento', 'post_status' => array('publish', 'private'), 'numberposts' => 999, 'orderby' => 'title', 'order' => 'ASC'));
    unset($values['options']);
    $values['options'] = array(''); //remove this line if you are using a checkbox or radio button field
    foreach($posts as $p){
      $values['options'][$p->ID] = $p->post_title;
    }
    $values['use_key'] = true; //this will set the field to save the post ID instead of post title
  }
  return $values;
}
#1073457

Above function list me properly Hotels (habitaciones will list the rooms), but I need Rooms of current hotel and I don't have idea how to do it (what to change).

#1073464

You wrote:

==> If you book 2 rooms, at once, this complicates things

Yes, people do that all the tine - ie to book two Familiar rooms with one submission. Why not??? That's the essence of topic.

==> he needs to edit or create a new booking.

But Toolset can do this only if customer is previously registered, what should not to be (there is entire problem). In Toolset is possible to connect repeated form only to (from) something what previously exists (so, customer), what should not to be case here (it is not either in real life). In other words, I tried to do that (successfully), to repeat rooms booking without customer. But I can;t after that to connect that two created bookings (logically) to one customer. And I cannot even to see any solution for that issue.

Connecting bookings per room to rooms for final booking is impossible, as in real life could happen in same moment from two customers to come booking on same room and than will be the mess. So, MUST BE CUSTOMER (but he can't previously to exists). No solution as far as i can see.

#1073465

Thanks for the details.

Let me reply below to sort out misunderstandings

1. Initial reason for mistake arise in your presumption that this project is copy of Booking.com (I admit, it looks like), but it is not.

I never assumed this, it's a comparison only
I understand that you do not want to rebuild that, and I understand much better the goal of your project seen the explanations.

2. Income model is Google, Facebook like model (kind of, not exactly, that's obvious), and not 'commission' model (booking. com) or monthly paid service model (Yelp like). It substantially change everything.

I am not sure to follow.
Do you refer to something more like a Community, like FB and Google+, where people can "post" their offer, and as well "book" offers?
That would surely change a lot.

3. Users (business owners) will get ALL SERVICES FREE, what completely exclude any of elements what you listed (image, price, etc...), actually exclude complex forms (idea is > contrary - simple, efficient).

I unterstand you do not require classic data for this - however it does not seem that you have simple data sets
The data sets are complex, related and lots of fields are required for them, right?

4. I understand that while this should not be a booking system, as others, it has one in common with them:
AVAILABILITY CHECKING
This is something we can and must do on all booking platforms, or else "offer and take" platforms, if the things we handle there are bound to time (which rooms rentals and similar, probably are, wether paid or not).

AVAILABILITY CHECKING is something that is difficult with Toolset.
Better is, to use a calendar Software or Software that allows Bookings and such (they also work with prices, or you can set 0.0 prices)

Toolset is not the right software for such a project.

If you just want a user to filter posts by date or date field, yes that can be done, but creating a booking, or availability system, with Toolset, is not the proper approach.
WordPress itself is, I am afraid, not the right tool for this.

I am not saying it cannot be done, I say, it is not the easiest way.

Yes, you can create listings, and even sort of booking systems or availability checks with Toolset - but it will never be the same as a tool that is designated to do that.
Toolset is designated to manipulate, display and query WordPress "Custom Types" and other, WordPress related content.

5. I do also not understand, why AVAILABILITY CHECKING is related to a customer to be able (and should to be able) to repeat rooms, service, product.

On the contrary.
To check availability of something, I must run a SEARCH, a COMPARISON, not add data.

I add data that later can be compared by someone.
That someone does not need to create that data to compare it.
Only if they want to add data, so to compare later, then yes we need this feature.

Is that what you refer to?
That in order to have data to compare, you need this to be created first?

That is correct, but in general, you do most of that in one step - mostly in the backend
Another step - usually the "User Experience" is comparing the data you entered, in a Search.

Now, I understand that in your system both a user can search, compare and create data.
But, those are different steps, not related to each other.

One can, if only possible there, add data in a step by step form, or, in the backend.
Then, the search / availability check can still happen in the front end.

I understand that you probably want this all as a nice flow in the front end, but when it comes to create and edit that data, there are still limitations and there will always be some (such as that you need data to connect it first).

Search and compare, check availability, etc is a Front end event, a search, which works no matter how you entered that data.

5. Given all that, I do not understand, why above facts you presented imply the next characteristics you outlined:

a) 'Reservation' data should not to be stored (expiration model could be used - or 'generic fields').

You mean the post you create expires after the exact amount of time the user entered as booking period.
That should be possible, as long we act on post forms.
After the post is expired it can for example change status or similar.
However, you have 0 control over this in the backend (you cannot list by, sort by, find by expiration date)
Your hosts have 0 control over who comes when to their home or offered place.
The only I can think of is a View that somehow gets those posts and lists/orders by that expiration date
I have done that in past, requires a bit of time but should be possible.

We will not discuss how to here, please open a new ticket for particular assistance.

b) Business owners should to confirm availability (briefly - nothing to do with project).

How?
See, that is what does not work here.

You want to not store data but allow people to check ... what data?
The only way, again, for a business to "check and confirm" availably is:
- get a view with currently not expired posts
- check their expirations (we could display that somehow)
- submit some kind of form that somehow confirms something (for example, it re-set the post to publish and expiration date as stored)

You have no email yet, no interaction of the user if he wants to change the date (requires custom code to update expiration date stored in DDBB when user edits booking)

Again, totally possible, as long you can apply API to forms.

Again, if assistance is required for this, new ticket please.

c) Customer data SHOULD BE STORED (VERY IMPORTANT).

I agree.
That would either happen (proper approach) on the User Profile - or, in the bookings created right?

That is no problem whatsoever with Toolset.
Toolset can store Users, and Post and related user Data. It can edit it and create it even.

d) Credit cards or not, that is also not part of the service (so, visible payments, confused you - that's links to customer payment gateways and not payment to PORTAL - as Booking.com) - so - IRRELEVANT.

Sure, that is no issue, but it does as well not explain why all this is related and requires this complex setup with a tool that is not designed to be a Booking (or else social platform, sharing, availability check) platform

It's designed for interacting with WordPress and create, query and show content created within.

Let's forget that point - it does not change the situation.

e) It is actually, not important either to store relationship Room - Customer (could to expire and 'trash').

This is the most crucial part in any system that offers anything at availability.

If you end up with 2 clients in the same room, you will not achieve what you want.
So, it is very important, I think, to have a connection of the person, the booking and the room

Of course, the room could just hold information about bookings, not users per se.
However, the room should have a method to set as available or not, I think? (Generally speaking)

f) Customers with higher demands (booking/customers management, will be able to activate third party services forms - to not extend here).

OK. I see a lot more complexity in this task
But that should probably be handled in another step

I am not sure however what point you want to make with all these points.

Most of this is possible, it's not the best tool to create such a system (call it booking system, or peer to peer system)
It requires a lot of custom logic.
It may require less complex setup if the features of the system are kept at the capacity of WordPress, which is a blogging tool.

Point 3 I do not agree.

I am not sure if in the screenshot I see a form to search, or submit something.

It does however not really matter.

1. Search for does NOT require you to ADD new, repeating, fields that belong to a room.
2. Instead it requires you to CHOOSE from the available items to find something
3. and if you create something, to then yes, you have to be able to add such repeating items, but you will not have to search by them

Both together, that does not work.

Several bookings equal to several forms submitted and several posts created.
Several things can be found instead in one search form, in a view.

Those are different things.

Related to doing that, with related posts, repeating fields, search and create in one, in 5 minutes, with ACF as depicted here:
https://toolset.com/forums/topic/repeater-fields-groups-in-cred-working/page/2/#post-1073456
I can explain to you exactly how to get Posts, that are related to another posts, with the Toolset API.
That, is the same as the used get_posts() in your custom function but uses our API:
https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/

If I recall right Room is a Child to Hotel, no?
So you replace the call to all posts in that function with a Toolset API call.

From:

$posts = get_posts( array('post_type' => 'alojamiento', 'post_status' => array('publish', 'private'), 'numberposts' => 999, 'orderby' => 'title', 'order' => 'ASC'));

It becomes:

$post_id == //The current Hotel Post or any Hotel Post ID
$posts = toolset_get_related_posts(
    '$post_id', // get posts related to this one
    'relationship_slug_here', // relationship between the posts
    'parent', // get posts where $post_id is the parent in given relationship
    $limit, $offset, // pagination
    array(),
    'post_id' // you want the post ID, could be object to
    'child'//return child post(s)
);

Above gives you the same as the get_posts, just, it gets related posts to a give hotel

We close this ticket here, as the issue reported:
Repeater Fields Groups in CRED working
is resolved.

They do, limitedly.

See you in eventual follow up threads!

#1073466

I did not see your other reply.

1. Yes, people do that all the tine - ie to book two Familiar rooms with one submission. Why not??? That's the essence of topic.

Of course.
And I repeat, last time:
Toolset is not a booking platform
Yes, you can create this - but it requires either more steps, or, a different setup where you store rooms for example in a field that you can select.
Just as Forms Commerce does it with Products, similarly, when you add payments to our Toolset Forms.

However.

Toolset is not a plugin to build a booking platform.
Yes you can search, and have something like a booking platform, but you are using this plugin on a Blogging Platform, with a Tool, that is not primarily made for this particular project.

2. But Toolset can do this only if customer is previously registered, what should not to be (there is entire problem).

If you want a user data, users need to be registered.

I do not think, Toolset asks you to add users to submit forms
Even guests can submit forms
But again, the intention of Toolset is not to allow a guest to use a booking platform but to allow a guest submit and edit WordPress Content if you want, display it, search it, etc.

3. In Toolset is possible to connect repeated form only to (from) something what previously exists (so, customer), what should not to be case here (it is not either in real life).

I have no idea why you say that and it is simply wrong

In Toolset, a Guest can add relationships and RFG thru Forms.

He/She does not need to be a user.
Correct me if wrong and do that in a new ticket - it would be a BUG.

If you refer to the fact that your customers are in fact posts, and the RFG, NEEDS a post to get connected to, then yes, sure, and that will never change

==> Head to any page, and set a parent to that page - which does not yet exist.
It won't work because there is no parent.
Yes, you can create the page.
But pages are not bound to parent, RFG ARE.
So, no, it is not possible, to create a RFG; and leave it there as a standalone post, and connect it later.

Not within the GUI, however.
I bet with you I am able to find a workaround for that.
For example - why not use a Dummy post, that LATER can be removed/ and RFG then connected to right parent, in the Form?
Yes, one more step, but if smoothly designed, this may be a possible solution!

It may actually even help, to "control" the booking made on that dummy post and then later "allow" this booking by actually connecting it to the right, expected parent.

Of course you need to have something in place to classify your bookings so to later natch them to the real rooms.
Just an idea.
I am not sure the could work, but I would probably try it if I would want to build this with Toolset

However, I have to say, I would not use it for this
I would get a Tool that is made for booking platforms.

However that is not topic 🙂

4. In other words, I tried to do that (successfully), to repeat rooms booking without customer. But I can;t after that to connect that two created bookings (logically) to one customer. And I cannot even to see any solution for that issue.

Sure, if that is a post type, the RFG, can only be added to an existing post.
Nothing to change here, as above shown, maximally we could workaround it for now.

5. Connecting bookings per room to rooms for final booking is impossible, as in real life could happen in same moment from two customers to come booking on same room and than will be the mess. So, MUST BE CUSTOMER (but he can't previously to exists). No solution as far as i can see.

That is what I refer to above towards end of #3 as well
As said, maybe let the user save a field in that RFG that states the room he wants, so you can grab that information from there?

Maybe even a hidden field can grab what the user "thinks to select"

But again, we are trying to get the impossible out of Toolset here.

It seems to me this is not the tool that will allow you to build 100% of this site.
Maybe 50%

Please, let us follow up on new dedicated tickets, this is not going anywhere here.

#1073468

I don't look nothing really complicated and finlly i figured how to simply explain 9and stay on topic). I will make it on website in Formidable and you will see how simple it is. I only have two issues with Formidable (not relevant here) and for same problem to do it with Toolset, I have one issue (topic). So, I thought that logically should be easier to solve one than two. In about 30 minutes will be form online and you will see how simple think I ask (I never even thought about any kind of booking platform - this is simple booking notification, not more and not less).

#1073470

Great.

Can you do that in a NEW Ticket please?

Explain what you submit and where we see what, I can take a look on Tuesday or Christian C. tomorrow, if you prefer a faster attention (I am out for 2 days now, weekend)

If we can see what you do with that ACF Form may we can do the same with Forms, let's see.
In a new ticket, please.

🙂

Thank you Ljuba!