Beispiel #1
0
?>
</h4>
    <?php 
// echo $this->render('_search', ['model' => $searchModel]);
?>

    <p>
        <?php 
echo Html::a('新增商品', ['create'], ['class' => 'btn btn-success']);
?>
    </p>

    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'showOnEmpty' => false, 'tableOptions' => ['class' => 'table table-striped'], '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' => 'list_img_url', 'label' => '小图', 'format' => 'html', 'value' => function ($model, $key, $index, $column) {
    if (!empty($model->list_img_url)) {
        $list_img_url = '<img src=' . $model->list_img_url . ' width=64px height=64px>';
    } else {
        $list_img_url = '';
    }
    return $list_img_url;
}, 'headerOptions' => array('style' => 'width:80px;')], ['attribute' => 'pub_userid', 'label' => '发布者', 'value' => function ($model, $key, $index, $column) {
    //return MGoods::getDetailCtrlOption($model->detail_ctrl);
    $user = MUser::findOne(['id' => $model->pub_userid]);
    return empty($user) ? "" : $user->username;
}, 'headerOptions' => array('style' => 'width:90px;')], ['attribute' => 'status', 'format' => 'html', 'label' => '发布状态', 'value' => function ($model, $key, $index, $column) {
    if ($model->status == 0) {
        return "<span style='color:red'>" . MGoods::getStatusOption($model->status) . "</span>";
    } else {
        return "<span style='color:green'>" . MGoods::getStatusOption($model->status) . "</span>";
Beispiel #2
0
/* @var $model app\models\MGoods */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="mgoods-form">

    <?php 
$form = ActiveForm::begin(['options' => ['enctype' => 'multipart/form-data']]);
?>

    <?php 
echo $form->field($model, 'title')->textInput(['maxlength' => 64]);
?>

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

    <?php 
echo $form->field($model, 'descript')->textInput(['maxlength' => 256]);
?>

    <?php 
echo $form->field($model, 'price')->textInput();
?>

    <?php 
echo $form->field($model, 'price_hint')->textInput(['maxlength' => 512]);
?>

    <?php