How to select existing record OR create new if not found and pass Values to another form

By: andy Morris | Asked: 08/30/2021
ForumsHow to select existing record OR create new if not found and pass Values to another form
andy Morris asked 3 years ago
Chris Adams replied 3 years ago

Hi Andy,

I'm not sure i understand the question fully? Do you want to show a list of entries to edit and then either select an entry or create a new one if no entries exist?

If you could give a bit more detail on what you want to achieve that would great?

2 Answers
andy Morris answered 3 years ago
Hi Chris, sorry this went to Junk. I appreciate your response and yes more detail would be good. here goes. My user creates a production name in Form A. They are then forwarded to form B where The first thing they do in form B is select a Production name from the list of productions they have entered.they  then enter a rental request in form B which references the production name from Form A. I have all this working. Later they may return and want to enter another rental request. If they start on Form B AND have already entered the production name they want, no problem. BUT if they start on form B and the production does not yet exist for them to select in Form A...  How do I get them back into Form A elegantly to enter a new production record, then back into Form B to enter the job against that production record. The first dropdown field in Form B to select the Production Name shows only those entered by the user. Is there a way first to have a constant dropdown value in that lookup field for any user that says"create new"? If that is selected can that trigger a redirect to Form A?   It would not be a big deal to just force every user to always start on form A but I found when the value did exist in form A and they selected it and hit submit, I could redirect to form B but it created a duplicate record of the value they selected in FormA... which I do not want. Much obliged. FF is powerful and I am learning a ton... but this one has vexed me for a few weeks now. Andy  
Chris AdamsChris Adams answered 3 years ago
Hi Andy, Thanks for the detailed description and additional information. I see what you're trying to do now.
You could do this in a few ways i think.
  1. You could have an initial question on Form B that says "Select an Order / Create New Order" or ssimilar. Based on what they pick then sends them on the right path (i.e. back to Form A or continue with Form B). You could use the page break or just conditional logic to hide everything else other than this question to begin with.
  2. You could use the frm_filtered_lookup_options hook to add a new option to the Lookup field (i assume it's a lookup field?) with a 'Create New' option as you said. You could then have a redirect in place if that value is selected to go back to Form A. I don't think there are examples of using it in exactly that on the FF KB but you could probably use onw of the examples there as a starting point.
  3. if you're using a Dynamic dropdown it's a bit easier to adjust the values so you could probably use the frm_show_it hook to add a new 'Create New' option.
There are probably a few other ways of doing it but off the top of my head i think those would be the one's i'd look into. I'll let you know if i think of anything else. Chris

Making the Best WordPress Plugin even better - Together

Take on bigger projects with confidence knowing you have access to an entire community of Formidable Experts and Professionals who have your back when the going gets tough. You got this!
Join the community
crossarrow-right