一丘
有一篇文章是我 之前写的,你可以参考下
一个字段关联我会,我的问题是不知道怎么同时两个字段关联另一个表的同一个字段
- 一丘 回答了问题 如何在一个关联里面,关联多个字段
- 一丘 回复了 johnny1991 的回答
参照yii2框架的rbac数据表
create table `auth_item_child` ( `parent` varchar(64) not null, `child` varchar(64) not null, primary key (`parent`, `child`), foreign key (`parent`) references `auth_item` (`name`) on delete cascade on update cascade, foreign key (`child`) references `auth_item` (`name`) on delete cascade on update cascade ) engine InnoDB;
我的表里面没有建外键,用的hasOne关联,在searchModel里面加public $member_name 来取得,所以不知道怎么弄。。。
- 一丘 提出了问题如何在一个关联里面,关联多个字段
你是要搜索吗?
我是这样做的。不知道你是不是要这个!<?=$this->render('_search', ['model' => $searchModel]); ?> 这是(index.php)
<?= GridView::widget([
(_search.php)
<?php $form = ActiveForm::begin(['action' => ['index'],'method' => 'get',]); ?>
<div class="col-lg-2 col-sm-2 col-xs-2" style="padding-left:20px;margin-top:10px">
<?= $form->field($model, 'type_id')->dropDownList(ArrayHelper::map($data,'id', 'type_name'),['style' => 'display:inline-block;','prompt'=>'请选择活动类别...'])->label(false) ?>
<?= Html::submitButton('搜索', ['class' => 'btn btn-primary']) ?> <?= Html::resetButton('重置', ['class' => 'btn btn-default']) ?></div>
<?php ActiveForm::end(); ?>
@刘先生 聪明,把搜索单独出来。。。
你是要搜索吗?
我是这样做的。不知道你是不是要这个!<?=$this->render('_search', ['model' => $searchModel]); ?> 这是(index.php)
<?= GridView::widget([
(_search.php)
<?php $form = ActiveForm::begin(['action' => ['index'],'method' => 'get',]); ?>
<div class="col-lg-2 col-sm-2 col-xs-2" style="padding-left:20px;margin-top:10px">
<?= $form->field($model, 'type_id')->dropDownList(ArrayHelper::map($data,'id', 'type_name'),['style' => 'display:inline-block;','prompt'=>'请选择活动类别...'])->label(false) ?>
<?= Html::submitButton('搜索', ['class' => 'btn btn-primary']) ?> <?= Html::resetButton('重置', ['class' => 'btn btn-default']) ?></div>
<?php ActiveForm::end(); ?>
你是自己写的表单搜索吧,那分页这些你也自己写了??????