Support for other field types like Link or Table fields

Created on 31 January 2025, 23 days ago

Problem/Motivation

Currently it doesn't support other field types with a different widget. For instance, ELB uses a different widget of `ext_link_blocklist_widget` or TableField using `tablefield`. But adding the widgets to the list of `SUPPORTED_FIELD_WIDGETS` is not enough because their field names for instance for the title of URL or the Caption of the table are different than the default field name for string-based fields.

Proposed resolution

So, I created a customized patch for what I needed but we should probably think of a better way of solving this. With the patch, not only those two widget names get added to the list of supported widgets, but also in `ajaxTranslateText` method, it adds a loop to go through all the field names of `value` (which is the default), `title` (for Links) and `Caption` (for tableField).
However, I'm not sure about the perfection of the solution but it works for me and my client.

Feature request
Status

Needs work

Version

2.0

Component

Code

Created by

🇫🇮Finland mitechworld

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

Comments & Activities

  • Issue created by @mitechworld
  • 🇫🇮Finland jhuhta

    Interesting. I don't think we should add direct support for various field types names provided by other contrib modules, but instead do something more generic, such as provide a hook or plugin type of approach that could add support for such so that module users could plug this into new field types.

    The problem might be to know beforehand what kind of field processing would be needed in processElement to enable this kind of pluggable solution. But do you get my idea? Would it be something that you could work on? The plugin approach could be better in a sense that this module could already include plugins for various field types. Or, if it is possible to write the code so that it already supports many kind of fields automatically, then a hook to alter the list of supported field types would suffice. Allowing to add the button for just type of field widget would probably be a bit risky?

  • 🇫🇮Finland mitechworld

    jhuhta, thanks for the suggestions. Could you take a look at the changes in the issue fork? Is it close to what you had in mind?

  • 🇫🇮Finland jhuhta

    I haven't had time to actually test it and check it properly. What I'd like to avoid though, is hardcoding contrib provided field types there - maybe either have it as an extendable structure or then get rid of of the thing completely and instead try to recognize if this or that field could have the feature enabled. The form mode config form shouldn't add the third party settings to every single existing field though.

  • 🇫🇮Finland mitechworld

    jhuhta, I'm not sure if I understood your point correct or not, but your problem is with these plugins only: `ExtLinkBlockListTranslatePlugin` and `TableFieldTranslatePlugin` ? or you mean specifically the field names defined in those plugins ? or even something else entirely?

  • 🇫🇮Finland mitechworld

    There is another complexity. Adding the Header widget when using heading module, is not enough to make the translation button work. The reason is that the actual text element is in a sub element called container when we want to access and update the text field through form and formState. I'll add this updated patch as a support for Header widget.
    Not sure how we can reflect this in the Fork Issue as the general solution.

Production build 0.71.5 2024