kristianmandrup/gmaps-autocomplete-rails

Put 'gmaps-output-longitude' and 'gmaps-output-latitude' to hidden field

mirap opened this issue · 2 comments

mirap commented

Is there any simple way how to put those values into hidden fields? I'm using gmaps-autocomplete-rails in form_for, so it would be quite handy.

Fork it, fix it, make a PR ;)

I just merged some pending pull requests and looked into the code. Yes, you can use hidden fields no problem. Nothing in the code dependent on the type of field, only that the input field has a value attribute. If you have any problems, it could be due to the update_ui function using .autocomplete which you can override to fit your needs.

// fill in the UI elements with new position data
function update_ui( address, latLng ) {
  $('#gmaps-input-address').autocomplete("close");
  $('#gmaps-input-address').val(address);
}