Managing Relationships in the Form Builder
I have a pretty complex requirement related to relationships in a form.
The form is in a RequisitionResource, and the Requisition has a Patient and a Guarantor. When a new requisition is being captured, the operator can use a searchable Select to find the patient, but if the patient cannot be found, a new one must be created without leaving the page.
I am trying two approaches, a modal (https://bit.ly/3TMF42c) and a Section using the relationship() method (https://bit.ly/3TFG3B6).
The modal works, and once a new patient is created it fills all the fields properly, including those in the Section. My problem here is that the modal is not the preferred approach for the client.
If a patient is found in the Select and selected, the Section fields are populated, and can be edited - first prize. However, if a new patient is created using the same fields, the patient_id Select is not populated, and it really should be required(). Is there a way I can make the Section "live()" or something like that?
The Guarantor is actually just another instance of a Patient model, and is often the same person. It is handled in the same way as the patient, with a Select, modal forms and a Section.
A pair of buttons are provided to copy the patient_id to the gurantor_id, which both work, but the Section for the Guarantor is not populated when the patient_id is copied over. This is a problem, because the Guarantor form has a couple of fields which the patient doesn't have, which need to edited.
The preference here is to stick to the relationship() method on the Section layout component and drop the modals altogether.
I would really, really appreciate any help or suggestions offered.
Source code: https://gist.github.com/nettsite/ff80a0a061dfd49bfede1ee9c6afb227
Source code: https://gist.github.com/nettsite/ff80a0a061dfd49bfede1ee9c6afb227
Gist
Patient and Guarantor Tabs for the Requisition form
Patient and Guarantor Tabs for the Requisition form - RequisitionResource.php
0 Replies