Problem/Motivation

I'd like to use an autocomplete field with custom options in a webform that is translated.

While the managed list of options are translatable, "custom" options are not.

Steps to reproduce

  1. Create a webform with an autocomplete field that uses custom options.

    e..g adding this element to the test_translation webform
    autocomplete_field_custom_options:
      '#type': autocomplete
      '#title': 'Autocomplete (custom)'
      '#format_items': comma
      '#autocomplete_items':
        - Seven
        - Eight
        - Nine
    
  2. Navigate to the Translate tab
  3. Edit a translation

Note that the custom options are not listed for translation.

Proposed resolution

Include autocomplete_items as a translatable property.

I think defining defineTranslatableProperties for webform\Element\WebformAutocomplete would do it.

  /**
   * {@inheritdoc}
   */
  protected function defineTranslatableProperties() {
    return array_merge(parent::defineTranslatableProperties(), ['autocomplete_items']);
  }

Remaining tasks

  1. Create a patch
  2. Write accompanying test

User interface changes

This would expose autocomplete custom options as translatable.

API changes

None.

Data model changes

None.

Issue fork webform-3219041

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

leeomara created an issue. See original summary.

jrockowitz’s picture

Version: 6.0.3 » 8.x-5.x-dev

This issue should also be addressed in 8.x-5.x.

Can you please create a PR for your branch and I will merge it? Thanks.

jrockowitz’s picture

Status: Active » Reviewed & tested by the community

leeomara’s picture

Thanks for the quick review and feedback.

I've made a new merge request targeting the 8.x-5.x. branch, MR39.

jrockowitz’s picture

Status: Reviewed & tested by the community » Needs work

The broken time test can be ignored. The other broken test needs to be fixed.

vsujeetkumar made their first commit to this issue’s fork.

jrockowitz’s picture

Status: Needs work » Reviewed & tested by the community
jrockowitz’s picture

  • jrockowitz committed 5d574c6 on 8.x-5.x authored by leeomara
    Issue #3219041 by leeomara, vsujeetkumar: Autocomplete custom options...
jrockowitz’s picture

Status: Reviewed & tested by the community » Fixed

  • jrockowitz committed 5d574c6 on 6.x authored by leeomara
    Issue #3219041 by leeomara, vsujeetkumar: Autocomplete custom options...
leeomara’s picture

Thanks for fixing that test @vsujeetkumar.

I'd not done any real work with PHPUnit in Drupal, and I couldn't spot the change to the `id=` part. I though I was going crazy not being able to make the results match.

Thanks @jrockowitz for being so responsive, and for the great module.

Status: Fixed » Closed (fixed)

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