I am simulating a multi page form setup where landlords are able to create a new property with a lease and tenants in a fluid process.
Start out
Where: Property listing page with create new property link.
Usage: Toolset view
Action: Landlord clicks create new property and are redirected to step 1.
Step 1
Where: Create new property page.
Usage: Toolset form - add new post - post type "property".
Relationship1: 1 property can be assigned to one Lease.
Relationship2: 1 property can be assigned to one Tenant.
Action: Landlord submits form and are redirected to step 2.
Step 2
Where: Create new lease page.
Usage: Toolset form - add new post - post type "lease".
Relationship1: 1 Lease can be assigned to one Property.
Relationship2: 1 Lease can be assigned to one Tenant.
Action: Landlord submits form and are redirected to step 3.
Step 3
Where: Create new tenant page.
Usage: Toolset view and Toolset form - add new post - post type "tenant".
Relationship1: Infinite Tenants can be assigned to one Property.
Relationship2: Infinite Tenants can be assigned to one Lease.
Action: Landlord submits form with ajax and stays on the page and creates a new tenants again and again.
Forms API Hooks
Are used to pre set relationship fields, otherwise my landlords would have to set in manually in every step which is would not make the flow seem fluid. The relationship fields are also hidden to the landlord as they are set backstage.
End result
Property, lease and tenant are created with relationships.
Challenge
Since Property and lease can have several tenants, i have a problem in the last step 3. I would like the landlord to be able to create several tenants to the property and lease. As Toolset forms only allows for creating 1 post at the time this posses a challenge.
Preferred solution
One way that would work for my, is simply to reload the "create new tenant page" with ajax and add a view to the page as well, that way it will be able to stay in the add tenants loop. It almost works and here comes the call for help. Creating the first tenant works just fine, but when creating the next tenant I cant use the Forms API Hook "cred_success_redirect" and set the relationships in the url. Be course I want the Landlord to stay on the same page - add tenant loop, but the "cred_success_redirect" is not working when the page stays the same. I would really appreciate if you could direct me to a solution, it took me ages to get this far and I am almost there.
/Thanks
I solved the issue with the hook api not working when viewing same page. In stead of "View form after submit" I chose "redirect to post" I then selected the same page and was able to the url as needed.
But simulating the add tenant loop like this gives my a problem with the view on the same "create new tenant page". I dont know how to only display the tenants belonging to the specific property and lease. Is there anyway for a view to fetch the $_POST[] parameters and use them to filter the result?
My issue is resolved now. Thank you!
Views: Filter by post relationship or repeatable fields group owner -> The post with ID set by the URL parameter. Works perfectly. Thanks for a great Toolset 🙂