Is there a way for users to add a new option to a dynamic field dropdown when filling out a form?

By: Michael Preslar | Asked: 01/02/2025
ForumsCategory: General questionsIs there a way for users to add a new option to a dynamic field dropdown when filling out a form?
Michael Preslar asked 4 days ago

I have a dynamic field dropdown that loads options from a second form. What I'd like to do: When the user types in something that's not in the current list, have the new item added to the list and displayed like the pre-existing options, instead of the "No results match" text.

Is this already possible?

My current plan is:

A) Form A has the dynamic dropdown (multiselect=true) that loads options from Form B

B) Form A also has a dropdown with the CSS class frm_Hidden. The idea being that new options get added

here

C) ?? - Not sure how to hook into the search

D) On the backend, have a filter for frm_pre_create_entry / frm_pre_update_entry that 1) goes through the new values, 2) does a $new_id = FrmEntry::create() to add it to Form B, 3) then adds $new_id to existing values array But, I'm not seeing a way to hook into the search.

Is this possible?  

1 Answers
Victor Font answered 2 days ago
I wrote a comprehensive answer to your question and it never posted. You're on the right track.
Michael Preslar replied 15 hours ago

Thanks Vic. I got this working this morning, so I'll close this question. But adding a couple of notes in case anyone else finds it useful.

On the front end, SlimSelect has an events.addable that I could hook into. Didn't need the hidden drop down.

On the back end, found that I had to use the frm_after_create_entry and frm_after_update_entry hooks, instead of the filters.

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