1

I have create Model/Source

But I want to add this in admin multiselect dropdown list

Like: enter image description here

$fieldset->addField(
        'special', 
        'multiselect',
        [
            'label' => __('Special'),
            'title' => __('Special'),
            'name' => 'special[]',
            'values' => // How to call here ?

That is my option value coming like this

Array
(
    [0] => Array
        (
            [label] => 
            [value] => 
        )

    [1] => Array
        (
            [label] => A
            [value] => 1
        )

    [2] => Array
        (
            [label] => B
            [value] => 2
        )

    [3] => Array
        (
            [label] => C
            [value] => 3
        )

        )
1
  • check my answer and add below code Commented Feb 25, 2019 at 7:00

1 Answer 1

1

You can try this way..

$fieldset->addField(
            'special', 
            'multiselect',
            [
                'label' => __('Special'),
                'title' => __('Special'),
                'name' => 'special[]',
                'values' => [
                ["value" => 1,"label" => __("A")],
                ["value" => 2,"label" => __("B")],
                ["value" => 3,"label" => __("c")],
            ]
          ]
       );
2
  • That is Static values. my values coming from a table. with a select query. I want dynamic. when I will add some new value in the table then it will come in drop down. Commented Feb 25, 2019 at 7:11
  • you have custom model source filed created? then your code update in question Commented Feb 25, 2019 at 8:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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