SELECT2 Box faulty

In order to prevent getting all values of database in DropDownBox I code like this in model:





    public static function get_ArrayOfMailAdresses() {

        $x = 0;

        $returnValue = array();

   	$valid_sem = '/;/';

   	$auswahl = Mailausgang::find(['id' => 'value'])->orderBy(['id' => SORT_ASC])->asArray()->all();

        foreach ($auswahl as $value) {

            if (!preg_match($valid_sem, $value['mail_antwortadresse'])) {

                $returnValue[$x] = $value['mail_antwortadresse'];

                //return yii\helpers\ArrayHelper::map($auswahl, 'mail_antwortadresse', 'mail_antwortadresse');

            }

            $x++;

        }

        return $returnValue;

    }



In my GridView, I’ll get all records withou semicolon in DropDownBox, as it’s intended.

If I select one, I will get no hit. Any ideas, where is bug?





        

                'attribute' => 'mail_antwortadresse',

           	'label' => Yii::t('app', 'Zieladresse'),

           	'contentOptions' => [

                    'style' => ['width' => '150px;']

           	],

                'value' => function($model) {

                    if ($model->mail_antwortadresse) {

                   	return $model->mail_antwortadresse;

                    } else {

                   	return NULL;

                    }

           	},

           	'filterType' => GridView::FILTER_SELECT2,

           	'filter' => Mailausgang::get_ArrayOfMailAdresses(),

                'filterWidgetOptions' => [

               	'pluginOptions' => ['allowClear' => true],

           	],

           	'filterInputOptions' => ['placeholder' => 'Mailadresse', 'id' => 'grid-zieladresse']

            ],



Unless I don’t have any plausible explanation, i solved problem coding like this





    public static function get_ArrayOfMailAdresses() {

        $auswahl = Mailausgang::find(['id' => 'value'])->orderBy(['id' => SORT_ASC])->where(['not like', 'mail_antwortadresse', '%;%', false])->asArray()->all();

        return yii\helpers\ArrayHelper::map($auswahl, 'mail_antwortadresse', 'mail_antwortadresse');

   }



I yet am interested knowing, why my first solution doesn’t work…