egeloen / IvoryGoogleMapBundle

Google Map API v3 integration for your Symfony2 project.
https://github.com/egeloen/ivory-google-map
MIT License
217 stars 152 forks source link

Places autocomplete element ID #132

Closed jensvandorpe closed 9 years ago

jensvandorpe commented 9 years ago

I would like to implement this form autocomplete in our symfony project: https://developers.google.com/maps/documentation/javascript/examples/places-autocomplete-addressform

But as the autocomplete input gets a generated id I cannot access it.

I found a function setInputId() in the following file: /vendor/egeloen/google-map/src/Places/Autocomplete.php but when I try to set it (just for testing) in the buildForm() function of /vendor/egeloen/google-map-bundle/Form/Type/PlacesAutocompleteType.php it doesn't seem to work.

Is there any reason this wasn't included in the default buildForm() function? And what could be a possible way to make this work?

Thanks in advance.

Jens

egeloen commented 9 years ago

The input id is basically the one generated by symfony. It is affected in the buildView and not the buildForm, this is why your own value was always overridden.

IMO, what you want to customize is not the input id which represents the html input id but the javascript variable name. Am I right?

jensvandorpe commented 9 years ago

@egeloen I overlooked the buildView function, thanks

I can now easily change the variable name in the buildView function using $autocomplete->setJavascriptVariable("test");

Thanks alot

egeloen commented 9 years ago

You can also affect it in the buildForm (it does not matter).