Hi,

I've setup the module and configure it follow the README.txt. However after I save the node with Place ID from google, others fields are still empty. As you can see from the screenshot below.
screenshot

Here is the screenshot from "Manage field"
https://www.drupal.org/files/issues/Screenshot%20at%202018-01-15%2020-33-31.png

Can someone suggest where I did wrong?

Thanks & best regards,
Max.

Comments

maxchock created an issue. See original summary.

hargobind’s picture

Status: Active » Postponed (maintainer needs more info)

Can you please post a screenshot of your "Manage fields" page for your content type? That will help me determine which modules you are using to add the data to each field.

hiramanpatil’s picture

StatusFileSize
new75.74 KB

I have followed the readme file to create required fields. When I save or update the node, the title of the node gets updated with place name. And also few terms gets added in taxonomy field.

There is no data in rest of the fields. No errors in error log as well.

Attached is the screen shot of manage-fields page of the content type.

hargobind’s picture

Did you enter your Google Places API Key as listed in step # 3 of the instructions? If you need an API key, follow this guide. If you are using a Geofield to store the Latitude/Longitude, you'll need to enter your API key on the configuration screen of that module too. (Nevermind that last sentence, it was incorrect.)

Can you also post a screenshot of the field configuration page for your Google Place ID field?

Please also type out the Place ID that you are trying to look up so I can test it on my end.

Can you also test out both of these place IDs and see if they work for you? They seem to fill all of the fields on my end.
NYC Health + Hospitals/Metropolitan (New York, USA) - ChIJG1z-2KhYwokRhPmjewNNWcc
Fortis Healthcare Limited (Delhi, India) - ChIJz3GebiACDTkRtGjNGCZUlrA

hiramanpatil’s picture

Yes, I have entered Google Places API key with the help instructions given here - Get API Key.

I have tried both places which you have given but only title of the node gets updated when node is saved.

1) NYC Health + Hospitals/Metropolitan - ChIJG1z-2KhYwokRhPmjewNNWcc
2) Fortis Healthcare Limited (Delhi, India) - ChIJz3GebiACDTkRtGjNGCZUlrA

I am using Geofield but didnt find configuration page for this module. Checking/Debugging Geofield to get configuration page to save Google Places API Key.

Please find attached screenshots of Google Place id field settings.

Thanks,

hargobind’s picture

Are any of the other fields even partially filled in? If so, that might tell us where it is failing.

The original screenshot shows "Malaysia" as the country, so I'm wondering if maybe that address field is configured in a way that is causing the problem. Can you show me your configuration of the address field? Also, maybe try and remove the address field temporarily and see if the other fields get populated.

You could also try debugging the return values to see if that holds an answer. First, go to the config page and change "Cache results" to "Disabled". Next, on roughly line 524 of gp.module, there's a line that says //watchdog('gp', '<pre>' . print_r($place, true) . '</pre>');. Remove the // from the beginning of that line. Then edit the node and just press Save. Then check your log and paste the "Message" contents of that log entry. Then re-add those slashes to disable the log message.

hargobind’s picture

More questions to help figure this out...

Are your fields assigned to a standard node, or a custom entity, or something else?

Is your site multilingual? Are you using any content translation modules to to translate entities or fields?

I may have found the source of this when I was testing using fields on a custom entity and $entity->language was set to a custom language. I'm going to test it further try out a change to the code.

hargobind’s picture

I ran into a bug with my own testing on a custom entity where the $entity->language was set to a value like en. Then when the other fields were populated, they were using the entity language rather than the $langcode which was being passed to gp_field_presave().

This is how the code appears when assigning a value to the other fields:
$entity->{$field_name}[$entity->language] = array(...some value...);
And this is what I changed to get it working on my end:
$entity->{$field_name}[$langcode] = array(...some value...);

I don't have time to create a multilingual installation and test it all, but I have attached patches which you can apply against the 1.2 stable release or the latest 1.x-dev version to test. Please let me know if this solves the issue for you. Also let me know if you cannot apply the patch and I'll send you a modified copy of the module file.

hargobind’s picture

Found a couple of bugs with my last approach, so please try these patches instead.

hargobind’s picture

Component: Miscellaneous » Code
Status: Postponed (maintainer needs more info) » Needs review
maxchock’s picture

Issue summary: View changes
StatusFileSize
new69.31 KB
maxchock’s picture

I've uploaded the manage field per request.

hargobind’s picture

Thanks Max. Can you try one of the patches that I attached above and let me know if it works for you?

hargobind’s picture

Title: Seems not working? » Seems not working on multilingual sites
Status: Needs review » Fixed

My testing indicates that the issue appeared specifically on multilingual sites. Fields were being set using the wrong language variable.

I updated the code to see if the field is translatable, and store the values in the correct language index.

I know I'm jumping the gun on this by committing changes, but I never heard back from anyone regarding the proposed patches. I'll offer a release candidate (1.3-rc1) for people to test out. If anyone finds issues with the changes, please reopen the issue and let me know ASAP.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.