$query = (new \yii\db\Query())
->select(['p.id', 'm.model', 'c.name as cat_name', 'l.name as color_name', 'l.color', 'b.name as brand_name', 't.content'])
->from(['p' => Products::tableName()])
->innerJoin(['m' => 'model_product'], 'm.id = p.model_id')
->innerJoin(['c' => 'categories'], 'c.id = m.category_id')
->innerJoin(['l' => 'color'], 'l.id = p.color')
->innerJoin(['b' => 'brand'], 'b.id = m.brand')
->innerJoin(['t' => 'model_content'], 't.id = p.content')
->where(['shops_id' => Yii::$app->user->id])->all();
$dataProvider = new ArrayDataProvider([
'allModels' => $query,
'key' => 'Review_ID',
'pagination' => [
'pageSize' => 10,
],
]);
return $dataProvider;
GridView::widget([
'dataProvider' => $dataProvider,
'tableOptions' => [
'style' => 'display: block; overflow: auto;',
'class'=> 'table table-striped table-bordered',
],
'columns' => [
'id',
'model',
'cat_name',
'color_name',
[
'attribute' => 'color',
'value' => function($data){
return $data['color']; // Да, именно так и вывел!!!
},
'format' => 'html',
],
],
]);
конечно переменная будет работать быстрее чем каждый раз вызывать одну и ту же функцию поиска по DOM
$(".select2-selection__clear").hide();
var checked = $(this);
var gallery = $(".sortable");
if(typeof checkbox_no == "undefined") {
checkbox_no = 0;
}
if (checked[0].checked) {
gallery.children("li").value = checked[0].value;
gallery.children("img").src = checked[0].value;
и т.д
}
$(document).on('click', '.checkbox_click', function () {
$(".select2-selection__clear").hide();
var checked = $(this);
var gallery_li = $(".sortable li");
var gallery_input = $(".sortable li input");
var gallery_link = $(".sortable li a");
var gallery_images = $(".sortable li a img");
if(typeof checkbox_no == "undefined") {
checkbox_no = 0;
}
if (checked[0].checked) {
gallery_input[checkbox_no].value = checked[0].value;
gallery_images[checkbox_no].src = checked[0].value;
gallery_link[checkbox_no].href = checked[0].value;
gallery_li[checkbox_no].className = '';
gallery_input[checkbox_no].className = 'form-control '+checked[0].id;
checkbox_no++;
} else {
$.each(gallery_input, function(id, param){
var id_name = 'form-control '+checked[0].id;
if(param.className == id_name){
for(id; id<gallery_input.length; id++){
if(gallery_li[id+1]){
if(gallery_li[id+1].className != 'hidden'){
gallery_input[id].value = gallery_input[id+1].value;
gallery_input[id].className = gallery_input[id+1].className;
gallery_images[id].src = gallery_images[id+1].src;
gallery_link[id].href = gallery_link[id+1].href;
} else {
gallery_input[id].value = '';
gallery_input[id].className = 'form-control';
gallery_li[id].className = 'hidden';
gallery_images[id].src = '';
}
} else {
gallery_input[id].value = '';
gallery_input[id].className = 'form-control';
gallery_li[id].className = 'hidden';
gallery_images[id].src = '';
}
}
}
});
checkbox_no--;
}
});(jQuery);
$colors = [
'1' => 'a52828', // где "1" это "$value", а 'a52828' это "$label" в 'item'
'2' => 'a5289a',
'3' => '000000',
'4' => '0600ff',
'5' => 'cacaca'
];
$form->field($products, 'color')
->radioList(
$colors,
[
'item' => function($index, $label, $name, $checked, $value) {
$return = '<input type="radio" id="color-'.$index.'" name="color" value="color-'.$index.'">';
$return .= '<label for="color-'.$index.'">';
$return .= '<span style="background-color: #'.$label.';">';
$return .= '<img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/242518/check-icn.svg" alt="Checked Icon"/>';
$return .= '</span>';
$return .= '</label>';
return $return;
}
]
)
->label(false);
<div class="color">
<div class="form-group field-products-color">
<input type="hidden" name="Products[color]" value=""><div id="products-color"><input type="radio" id="color-1" name="color" value="color-1"><label for="color-1"><span style="background-color: #a52828;"><img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/242518/check-icn.svg" alt="Checked Icon"></span></label>
<input type="radio" id="color-2" name="color" value="color-2"><label for="color-2"><span style="background-color: #a5289a;"><img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/242518/check-icn.svg" alt="Checked Icon"></span></label>
<input type="radio" id="color-3" name="color" value="color-3"><label for="color-3"><span style="background-color: #000000;"><img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/242518/check-icn.svg" alt="Checked Icon"></span></label>
<input type="radio" id="color-4" name="color" value="color-4"><label for="color-4"><span style="background-color: #0600ff;"><img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/242518/check-icn.svg" alt="Checked Icon"></span></label>
<input type="radio" id="color-5" name="color" value="color-5"><label for="color-5"><span style="background-color: #cacaca;"><img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/242518/check-icn.svg" alt="Checked Icon"></span></label></div>
<p class="help-block help-block-error"></p>
</div>
</div>
кст да, как вариант можно и переопределить)
www.yiiframework.com/doc-2.0/yii-grid-actioncolumn...