1

I'm testing to add a multiselect input in my BO form. But, the multiselect output is broken (however, the value selected is really selected in BO, and values are assigned). When I select a value, the multiselect selects all the values (all the values are highlighted ; just graphically).

My XML :

<field name="my_field">
        <argument name="data" xsi:type="array">
            <item name="options" xsi:type="object">MyCompany\MyModule\Model\Config\Source\Content\TagSelect</item>
            <item name="config" xsi:type="array">
                <item name="dataType" xsi:type="string">text</item>
                <item name="label" translate="true" xsi:type="string">Tags</item>
                <item name="formElement" xsi:type="string">multiselect</item>
            </item>
        </argument>
    </field>

TagSelect File :

public function toOptionArray()
{

    return [
        ['value' => MyInterface::TAG_TAG1TEST, 'label' => MyInterface::TAG_TAG1TEST],
        ['value' => MyInterface::TAG_TAG1TEST, 'label' => 'test'],
        ['value' => MyInterface::TAG_TAG1TEST, 'label' => 'test']
    ];
}

Thanks!

  • Please code of TagSelect – Amit Bera Feb 27 at 8:04
  • Please see the second block of code – Thomsath Feb 27 at 8:15
  • where you have implement this muiltselect .At ui form of admin or checkout – Amit Bera Feb 27 at 8:18
  • I implement it in ui_component, for form here – Thomsath Feb 27 at 8:20
  • 'value' => MyInterface::TAG_TAG1TEST should not be same for all option. – Amit Bera Feb 27 at 8:25
1

As per as, Amit Bera comment:

All the option's value is the same MyInterface::TAG_TAG1TEST that why you are getting the issue. Each option value should be unique like:

public function toOptionArray() {
    $options = [];
    $options[] = ['value' => MyInterface::TAG_TAG1TEST, 'label' => MyInterface::TAG_TAG1TEST];
    $options[] = ['value' => MyInterface::TAG_TAG2TEST, 'label' => 'test2'];
    $options[] = ['value' => MyInterface::TAG_TAG3TEST, 'label' => 'test3'];
    return $options;
}
0

After toOptionArray Function Call Below Function

public function getAllOptions()
{
       return $this->toOptionArray();
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.