Hi all, I promise I searched all around and couldn't find what I needed. I have a "Projects" content type with basic fields, including a 'Project Address' text field. I also have the Geolocation module installed and a corresponding field added for it in my Projects entity. This field is called 'location'. If you type an address into the textbox, the widget maps it and it works perfectly. However this leaves the user typing in the address twice. Once for the project address and once for the location textbox.

On the node add form, how can I add some custom js to populate the location textbox with the value in the Project Address textbox after it is updated? I think knowing this information will be pivotal in the long run, for other things I am doing as well. I have started trying to make a module that hooks the node add form, but I am little lost with how to refer to those specific fields from that module, as well as where to make a js function and call it.

In the Geolocation Module, I found the "Location" text box element, and I can set its value with a string. Can I just add something to this module to grab the address from the other Project Addressfield?

I have also tried to do this with the Calculated Field module, but it cannot set the value of another field, only the value of itself. I have also tried to accomplish this with the GeoCode/GeoPHP module. This module gives you a formatter that can geocode a different field, such as Project Address. Unfortunately this only works with the Address Field module installed and implemented on the field you are trying to geocode. And I do not want to use the Address Field module to handle the project address due to previous experiences with it.
Plus, I think knowing how to customize Drupal in this way is the correct direction I need to go in.

Any help would be greatly appreciated, thank you!

Comments

nevets’s picture

May be a silly question but why two fields? Why not make the "project address" field a geo-location field?

mattc321’s picture

I would support doing that accept the only way (that I know how) is to make "project address" a collection with the "postal address" field type provided by the address field module. Which has some other problems with views building and such. I will definitely do this if it comes down to it. I was just hoping to not have to use the address field module though.

nevets’s picture

I would use the Address Field module for the project address along with Geofield and Geocoder for the address encoding.

WorldFallz’s picture

seconded-- i use this combo all the time and it's brilliant!