Problem/Motivation

The module renders text strings that are hard-coded. For example:

  • the help text that displays below the map when using the openlayers widget
  • the label for the geocode button

It seems a better practice to expose these text strings as settings to allow users to override the 'default' value of these strings. As it stands now, a hook implementation is required to override these strings.

Proposed resolution

Expose these text strings as settings in the admin settings form.

Remaining tasks

Review and test.

User interface changes

Slight.

API changes

None.

Data model changes

None.

Addendum

A strange thing happened on the way to the form.

Unexpectedly, adding form elements to expose these strings results in a change to the rendered order of other elements on the form. In particular, the 'default value' fieldset added by Field API is now enclosed in the nested 'Geocoder settings' fieldset defined by this module. This fieldset contains the form elements from geocoder_field_widget_settings_form(). So the default value element is tucked between the 'Geocoder' (geocoding handler) select element and the 'Multi-value input handling' select element.

This re-ordering is a result of:

  • goefield using the '#prefix' and '#suffix' properties to wrap the elements from geocoder_field_widget_settings_form() in a fieldset.
  • the flattening of the render array done by core in field_ui_field_edit_instance_pre_render().

The core routine flattens the render array after the '#weight' values have been set. The 'default value' fieldset has a weight that matches the 'Multi-value input handling' select element. Now that the two elements are at the same depth in the render array, the default value element sorts ahead of the other element. This results in the default value element being wrapped inside the nested 'Geocoder settings' fieldset defined by geofield.

The comment in field_ui_field_edit_instance_pre_render() notwithstanding, I do not see what is so visually appealing about removing the fieldset elements or conversely so unattractive as to retain the individual fieldset elements on the instance settings form. It seems an obvious bug in core to flatten the render array and not recalculate the weights on the form elements.

In the absence of a change to core in this regard, it seems appropriate to remove the '#prefix' and '#suffix' properties mentioned above. The elements will still weight in the odd manner but at least the default value element will not be wrapped in another fieldset.

Also, the same re-ordering of form elements occurs on the settings form for other widgets provided by the geofield module.

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
8.72 KB

Attached patch implements proposed resolution.