We are designing a search fragment that will reside at the beginning of every form. The search fragment will allow a user to select one customer from a number of customers displayed. Once the user selects a customer, the search fragment will populate the main (parent) form with the customer data and then the search fragment should disappear.
We have a mock-up of the search fragment, but questions are surfacing as to the best way to integrate this into the form. Each form has different "customer data" fields that it needs from the search, for example, one form needs customer name and account while another form only needs customer name.
Here are some questions that are surfacing:
1. Should the search fragment "poke" the information into the parent form once the user makes a selection? If so, the fragment needs to detect which form it's on and send only the data the form needs. This will make the search fragment's javascript more complex.
2. Or, should the parent form "grab" only the information from the search fragment that it needs? This localizes the javascript to the parent form, leaving the search frag more generic. In this scenario I envision that once a user selects a customer, all customer information will be plopped into hidden fields on the search frag and the parent will use only the data that it needs.
Is there a best practice for doing something like this? Lessons learned?
Thanks,
Elaine