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
        )

        )
  • check my answer and add below code – Rakesh Donga Feb 25 '19 at 7:00
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")],
            ]
          ]
       );
| improve this answer | |
  • 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. – Hansraj Systematix Feb 25 '19 at 7:11
  • you have custom model source filed created? then your code update in question – Rakesh Donga Feb 25 '19 at 8:54

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.