S
S
Sergey Beloventsev2018-12-10 22:59:39
Yii
Sergey Beloventsev, 2018-12-10 22:59:39

Why doesn't templateResult work for kartik-v select2?

the code

<?= $form->field($model, 'color')->widget(Select2::class,[
                'data'=>ProjectStageField::$colorClass,
                'pluginOptions'=>[
                    /*'escapeMarkup' => new JsExpression('function (state) {return \'<span class="badge badge-lg badge-\'+state.id+\'">\'+state.id+\' </span>\';}'),*/
                    'templateResult' => new JsExpression('function (state) {return \'<div class="col flex-shrink-0 table-custom-stage"><span class="badge badge-lg badge-\'+state.id+\'">\'+state.id+\' </span></div>\';}'),
                    'templateSelection' => new JsExpression('function (state) {return \'<div class="col flex-shrink-0 table-custom-stage"><span class="badge badge-lg badge-\'+state.id+\'">\'+state.id+\' </span></div>\';}'),
                    ]
                ]) ?>

I get like this it 5c0ec59345331310226926.pngshould be something like 5c0ec5a8871a4171420813.png why don't you tell me?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
J
jnas, 2019-02-11
@jnas

Did you figure it out?, also faced this

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question