Suggest

Suggest control

Parameters you can pass

ParametersData typeDescription
namestringName of input that will be used in the form
idstringHidden input ID (stores the value)
itemsarray of objArray of Suggest values
selectedstringID of selected value from items array
class_namestringWrapper class (if several classes passed, divide them by Space)
placeholderstringPlaceholder
disabledbooleanShows if it's disabled

Parameters of items

ParameterData typeDescription
idstringID of the value that will be pasted into the data-attribute data-value-id of the input
valuestringValue (text)
custom_classstringCustom Suggest element class

Default

self.render({ ref: '/tmpl/controls/suggest.twig' }, {
    name: 'animal',
    items: [
      { id: 1, value: 'Cat' },
      { id: 2, value: 'Dog' },
    ],
    class_name: 'my-custom-suggest'
  });

Selected

self.render({ ref: '/tmpl/controls/suggest.twig' }, {
    name: 'animal',
    items: [
      { id: 1, value: 'Cat', custom_class: 'custom-classname-if-needed' },
      { id: 2, value: 'Dog' },
    ],
    class_name: 'my-custom-suggest',
    selected: 2
  });