S
S
Silverviql2018-04-28 14:41:28
css
Silverviql, 2018-04-28 14:41:28

How to display labels in kartik\grid\ExpandRowColumn from Select2 widget separately from each other:?

Now I have the value of the labels displayed in ExpandRowColumn
Now I have this:
5ae45c3c42cc0828547379.png
I'm trying to do this:
5ae45de4da868466346688.png

[
                'attribute' => 'tag',
                'format' => 'raw',
                'contentOptions' => ['class' => 'tr110'],
                'value' => function($model){
                    return $model->tags != null ?  '<div class="markerOrder">'.$model->getTagsAsString('gridview').'</div>' : false;
                }
            ],

public function  getTagsAsString($view)
    {
        if ($view == 'gridview'){
            $tags = array_slice($this->tags, 0, 5);
            $arr = ArrayHelper::map($tags, 'id', 'name');
        } else {
            $arr = ArrayHelper::map($this->tags, 'id', 'name');
        }
        return implode(', ', $arr);
    }

Widget for selecting markers.
<?= $form->field($model, 'tags_array')->widget(Select2::className(), [
                    'data' => ArrayHelper::map(Tag::find()->all(), 'id', 'name'),
                    'language' => 'ru',
                    'options' => [
                        'placeholder' => 'Выберите тэг',
                        'multiple' => true
                    ],
                    'pluginOptions' => [
                        'allowClear' => true,
                        'tags' => true,
                        'maximumInputLength' => 10,
                    ],
                ]);
        ?>

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question