Field description overwritten with Geometry Validation text

Created on 6 April 2022, over 2 years ago
Updated 24 November 2023, 10 months ago

Problem/Motivation

This is a regression from 🐛 Field description overwritten with Geometry Validation text Fixed .

GeofieldDefaultWidget overrides the user defined field description in

  /**
   * {@inheritdoc}
   */
  public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) {
    $element += [
      '#type' => 'textarea',
      '#default_value' => $items[$delta]->value ?: NULL,
    ];

    if ($this->getSetting('geometry_validation')) {
      $element['#description'] = $this->t('Geometry Validation enabled (valid WKT or Geojson format & values required)');
      $element['#element_validate'] = [[get_class($this), 'validateGeofieldGeometryText']];
    }
    else {
      $element['#description'] = $this->t('Geometry Validation disabled (invalid WKT or Geojson format & values will be set as NULL)');
    }

    return ['value' => $element];
  }

with the Geometry validation notice.

Expected would be to keep the user entered description and append the validation text.
Completely removing the field description is a major problem as it breaks core functionality.

Field descriptions are important for UX to tell users how to use the form correctly.

Steps to reproduce

Use a Geofield, add a field description and afterwards select a Geofield widget (in our case we used "Leaflet Map (default)". Go to the content edit form and see the field description is overwritten.

Leaflet widget inherits from the Geofield file.

Proposed resolution

Append the notice instead of overwriting the user defined #description.

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

🇩🇪Germany Anybody Porta Westfalica

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024