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
- 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 - Navigate to the Translate tab
- 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
- Create a patch
- 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
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
Comment #2
jrockowitz commentedThis 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.
Comment #4
jrockowitz commentedComment #6
leeomaraThanks for the quick review and feedback.
I've made a new merge request targeting the 8.x-5.x. branch, MR39.
Comment #7
jrockowitz commentedThe broken time test can be ignored. The other broken test needs to be fixed.
Comment #9
jrockowitz commentedComment #10
jrockowitz commentedComment #12
jrockowitz commentedComment #14
leeomaraThanks 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.