Umbraco Forms - Auto-populate fields with AJAX fetch
Hey Umbraco Forms fans!
Version numbers upfront: Umbraco v8.6.6, Umbraco Forms v8.5.5.
I'm trying to figure out a good way of achieving the following...
On my form, I have address fields (e.g. Address1, Address2, City, Postcode), my client would like the address fields to be auto-populated by a postcode lookup. I already have an API for the postcode lookup, (via JS/AJAX request).
Does anyone know if there is an existing way to do this with Umbraco Forms? or should I be developing my own custom field type for this? or hacking around with JS until I can make it work?
I've tried searching around to see if anyone else has tried this before, but my google-fu is failing me.
Thanks in advance!
Cheers,
- Lee
Note: I tried to post this question in the Umbraco Forms forum category, but it appears that all new questions are under the "Using Umbraco And Getting Started" category. ¯\_(ツ)_/¯
Hi keilo, sorry to say that it was for a client project that I no longer have access to the source code, (and I can't quite recall how I went about coding it - given it was 3 years ago - a lot has happened since then, the cursed covid years!)
Umbraco Forms - Auto-populate fields with AJAX fetch
Hey Umbraco Forms fans!
I'm trying to figure out a good way of achieving the following...
On my form, I have address fields (e.g. Address1, Address2, City, Postcode), my client would like the address fields to be auto-populated by a postcode lookup. I already have an API for the postcode lookup, (via JS/AJAX request).
Does anyone know if there is an existing way to do this with Umbraco Forms? or should I be developing my own custom field type for this? or hacking around with JS until I can make it work?
I've tried searching around to see if anyone else has tried this before, but my google-fu is failing me.
Thanks in advance!
Cheers,
- Lee
Hi,
I would go with a custom field. That way you can include the JS as you need it.
For working out which ones to populate you could create a mapping similar to how I do in https://github.com/Matthew-Wise/umbraco-forms-campaign-monitor. I have done similar since in v8 but its not somewhere I can link to :)
Matt
Thanks Matt, that's most helpful!
I thought I'd need to take the custom field-type approach, but wanted to see if/how anyone else had done it.
I'll take a look at the way you've done the mapping, (in "listmapping.html"). Good inspiration, thank you!
Cheers,
- Lee
Hi Lee
I am too looking for this with Forms. If you happen to recall how did it end up could you share the code ?
cheers
Hi keilo, sorry to say that it was for a client project that I no longer have access to the source code, (and I can't quite recall how I went about coding it - given it was 3 years ago - a lot has happened since then, the cursed covid years!)
hear you Lee!
thought I would try my chance, thanks!
is working on a reply...