craft3-templateselect icon indicating copy to clipboard operation
craft3-templateselect copied to clipboard

FR: Use autosuggest component for template selection

Open tomkiss opened this issue 2 years ago • 2 comments

This fork changes the plugins form element to use the autosuggest component, which improves template selection through the improved UI.

tomkiss avatar Sep 13 '23 18:09 tomkiss

@tomkiss Thanks for this PR! I didn't actually notice it until I did a major change where I added support for "beautifying" the paths and file names in the template select input.

Do you know if the autosuggest field has a way to control the rendering of the value?

sjelfull avatar May 12 '24 20:05 sjelfull

Hi @sjelfull,

You can't really style as such, but you can provide a "hint" that will render in the field.

For example, when rendering a field normally, you can send it something like this:

  'data' => ['Domestic Cat', 'Leopard', 'Lion']

But, you could use the hint property to improve what's displayed. Like so:

  'data' => [
      [
          'name' => 'Domestic Cat',
          'hint' => 'Your friend at home',
      ],
      [
          'name' => 'Leopard',
          'hint' => 'Classic Apple operating system',
      ],
      [
          'name' => 'Lion',
          'hint' => 'MGM',
      ]
  ]

...which would result in a UI that renders something like this:

Screenshot 2024-05-13 at 13 41 15

So, you could lead with the template name, then hint the full path?

tomkiss avatar May 13 '24 12:05 tomkiss