Exemplo n.º 1
0
    <//?= $form->field($model, 'detail_ctrl')->textInput() ?>

    <//?= $form->field($model, 'pics_ctrl')->textInput() ?>
-->

    <?php 
echo $form->field($model, 'office_ctrl')->dropDownList(MGoods::getOfficeCtrlOption());
?>

    <?php 
echo $form->field($model, 'package_ctrl')->dropDownList(MGoods::getPackageCtrlOption());
?>

    <?php 
echo $form->field($model, 'detail_ctrl')->dropDownList(MGoods::getDetailCtrlOption());
?>

    <?php 
echo $form->field($model, 'pics_ctrl')->dropDownList(MGoods::getPicsCtrlOption());
?>


    <div class="form-group">
        <?php 
echo Html::submitButton($model->isNewRecord ? '新增' : '修改', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
?>
    </div>

    <?php 
ActiveForm::end();
Exemplo n.º 2
0
    <p>
        <?php 
echo Html::a('新增商品', ['create'], ['class' => 'btn btn-success']);
?>
    </p>

    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['attribute' => 'goods_id', 'label' => '商品编号', 'headerOptions' => array('style' => 'width:50px;')], 'title', ['attribute' => 'goods_kind', 'label' => '分类', 'value' => function ($model, $key, $index, $column) {
    return MGoods::getGoodsKindOption($model->goods_kind);
}, 'filter' => MGoods::getGoodsKindOption(), 'headerOptions' => array('style' => 'width:120px;')], ['attribute' => 'price', 'headerOptions' => array('style' => 'width:80px;')], ['attribute' => 'price_old', 'headerOptions' => array('style' => 'width:80px;')], ['attribute' => 'list_img_url', 'label' => '小图', 'format' => 'html', 'value' => function ($model, $key, $index, $column) {
    return '<img src=' . $model->list_img_url . ' width=64px height=64px>';
}, 'headerOptions' => array('style' => 'width:80px;')], ['attribute' => 'body_img_url', 'label' => '大图', 'format' => 'html', 'value' => function ($model, $key, $index, $column) {
    $len = 0;
    $imgHtml = "";
    $imgs = explode(";", $model->body_img_url);
    foreach ($imgs as $img) {
        $len++;
        if (sizeof($imgs) == $len) {
            break;
        }
        //分号分割后,数组最后一项为空,剔除
        $imgHtml = $imgHtml . '<img src=' . $img . ' width=45px height=45px>';
    }
    return $imgHtml;
}, 'headerOptions' => array('style' => 'width:160px;')], ['attribute' => 'detail_ctrl', 'label' => '显示详情', 'value' => function ($model, $key, $index, $column) {
    return MGoods::getDetailCtrlOption($model->detail_ctrl);
}, 'filter' => MGoods::getDetailCtrlOption(), 'headerOptions' => array('style' => 'width:90px;')], ['class' => 'yii\\grid\\ActionColumn']]]);
?>

</div>