September Dublin Monthly Meetup cancelled due to DrupalCon

rjfg's picture

Hi all.

Our September Monthly Meetup in Dublin has been cancelled due to DrupalCon taking place during the same week.

The next meetup will be on Wednesday, October 25, 2017, 7:00 PM. See you then. http://meetu.ps/c/1M40b/sr3bP/f

Comments

The one month I have a questions to ask ...

frankdesign's picture

Hi all

The one month I have a question to ask at the meet-up and it's been cancelled! Just my luck!

Hope Vienna was fab for those who were lucky enough to travel - not as fab as Dublin of course ;o)

Anyway, I hope someone can point me in the right direction. I'm not having much luck with Google or asking on Drupal.Stackexchange. I'm building a website, part of which will advertise cars for sale. So on a node create form, a logged in seller will enter a reg number, click a button and all the details of that car will populate various fields like Make, Model, engine size etc... The car details are being supplied from a 3rd party via a HTTP GET call and are supplied as JSON. What the best way to build this into the node edit form? Sorry, I know that's a massive question, but I'm really just looking for pointers to get me started. If I know what to look for, I'm sure I'll find the answer, although I'm sure I'll probably have more detailed questions once I get going.

Thanks

Frank

P.S. It's a Drupal 8 site.

Assuming this is all still in

stella's picture

Assuming this is all still in the create node form (ie. not submitted), then you will need an ajax button for them to submit the query to a callback function which will query the API and return the data to Drupal. You can add the button in a hook_form_alter.

The ajax callback function, then needs to rebuild the node create form with the populated data (guessing as #value rather than #default_value if not to be edited, and #disabled too) and return the rebuilt form.

It's a bit more complicated than I can put into a comment - but this stack exchange thread looks to be along the same lines: https://drupal.stackexchange.com/questions/223257/rebuild-form-element-w...

Drupal Camp Dublin is on Oct 20 and 21st, so if you don't get it sorted before then, we can work through it at the camp. Otherwise ping me beforehand if you can't wait that long.