Problem/Motivation

The options in the 'geocode from field' on the field UI edit form include all fields of the entity type. This contradicts the code in the geocoder_field_widget_settings_form() that initially restricts the list to fields on the entity bundle. The other fields on all bundles of the entity type are incorrectly included by the call to entity_get_all_property_info().

To reproduce the problem, simply add a geocoder field to a bundle and look at the list of options in the select element on the field instance settings form.

Proposed resolution

Replace the call to entity_get_all_property_info() with entity_get_property_info().

Remaining tasks

Review. Are there test assertions to be changed?

User interface changes

No change, just less options in select element.

API changes

None.

Data model changes

None.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

solotandem created an issue. See original summary.

solotandem’s picture

Status: Active » Needs review
FileSize
1.18 KB

Attached patch implements proposed resolution (and adds missing new line to end of file).

solotandem’s picture

Regarding the 7.x-2.x branch:
- this bug is also present in geocoder_field_field_widget_settings_form()
- in addition, the above form builder also appears to have lost the filtering on 'all valid fields that we both support' as the code snippet below indicates all entity fields are added to $valid_fields

  // Get a list of all valid fields that we both support and are part of this entity
  foreach ($all_fields as $field) {
    if (array_key_exists($field['field_name'], $entity_fields)) {
      $valid_fields[$field['field_name']] = sprintf('%s (%s)', $entity_fields[$field['field_name']]['label'], $field['field_name']);
    }
  }

I will leave it someone else to port this patch to the 2.x branch.

solotandem’s picture

Attached patch implements proposed resolution (it removes the added new line in earlier patch and applies to latest stable release).

  • Pol committed ff14320 on 7.x-1.x authored by solotandem
    Issue #2797485 by solotandem: Options in 'geocode from field' should not...
Pol’s picture

Status: Needs review » Fixed

Thanks!

Status: Fixed » Closed (fixed)

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

Johan den Hollander’s picture

Pretty sure this broke the entity_property_info_alter implementation of this module.

This is my code

function MYMODULE_fields_entity_property_info_alter(&$info) {
  $info['node']['bundles']['location']['properties']['custom_address'] = array(
    'type' => 'text',
    'label' => 'Custom adress (from other fields)',
    'getter callback' => 'MYMODULE_fields_location_full_address',
  );
}

$info before and after:
Before
After