Hi Nick,
Thanks for writing back.
> Unfortunately, in our solution, I think we will still need a single form to add/edit a single booking that allows users to select a "hall" and then only "rooms" belonging to that "hall". The scenario is that we may get a booking request for a particular hall and room but that particular combination is not available and we need to update the request.
- Ok, in that case, the built-in relationship fields won't work, because they won't offer the dependent filtering option.
You'll have to include custom select fields in the form and populate and update their values, through custom script and AJAX calls.
For more personalized assistance around custom code, you can also consider hiring a professional from our list of recommended contractors:
https://toolset.com/contractors/
> I have noticed that the options open to relationship fields on "Create new" forms are different to "Edit existing" forms. On "Create New" forms, it is possible to set the value of the relationship field from a query string parameter.
For "Edit existing" forms, the option to set relationship field values from a query string parameter is not present. With this in mind, is there a "best practice" way to set the "selected" values of relationship fields using javascript.
- It makes sense that the option to set the default value in the relationship works in the 'add new' form, but not in the 'edit existing' form. When editing an existing post, the field needs to show which related post is already connected.
By default, the relationship field uses the 'select2' script for the autocomplete feature. But it can be disabled using the use_select2='never' attribute in the 'cred_field' shortcode:
https://toolset.com/documentation/programmer-reference/forms/cred-shortcodes/#cred_field
Without 'select2' script, the field would be a regular 'select' type input field.
regards,
Waqar