Yii2.0 的 GridView 问题 [ 2.0 版本 ]
[
'label'=>'确认订单',
'format'=>'raw',
'value'=>function($model,$model1){
Modal::begin([
'id'=>'myModal',
'header' => '<h2>增加人数</h2>']);
$form = ActiveForm::begin(['action' => ['order/update','id'=>$model->id,'cc'=>1], 'method'=>'post']);
$form->errorSummary($model);
echo $form->field($model1,'club_id')->textInput(['value'=>"order_booktee.club_id"]);
echo $form->field($model, 'buyer_id')->textInput() ;
echo $form->field($model, 'status')->textInput() ;
echo Html::submitButton( Yii::t('app', '增加人数'), ['class' => 'btn btn-success']);
ActiveForm::end();
Modal::end();
return Html::button('<b>增加人数</b>',[ 'data-target'=>'#myModal','datatoggle'=>'modal']);
}
],
我在gridview
中用了个modal
组件 想在modal
里面显示club_id
这个字段 但是这个字段是另外一张表的字段 就是关联的那张表 请问我应该怎么写才能把这个字段显示并把内容显示出来?求教啊
共 3 个回答
-
试试这个:
public function getClubId() { return $this->hasOne(order_booktee::className(), ['club_id' => 'id']); }
共 4 条回复你现在处理的表示被关联表(从表)吧? 可能是你的问题我理解错了。不过下面的说明可以参考下:
Apart from hasMany() , ActiveRecord also has the hasOne() method, which accepts the same arguments, but the meaning of the second argument is changed: in hasMany() we point from the related table to this table, but in hasOne() , we point from this table to the related one. Note that we don't technically need the FOREIGN KEY defined in the database tables for this relation to work, as we specify the relation manually at the application level. The foreign keys definition is there for two reasons: • It's a documentation in code: anyone reading the database schema will be able to understand that there is a logical relation between tables. • Gii can automatically generate the relation methods based on the foreign keys defined in tables. It generates relation methods from both sides of the relation;
kkk
注册时间:2015-03-06
最后登录:2024-08-22
在线时长:88小时45分
最后登录:2024-08-22
在线时长:88小时45分
- 粉丝5
- 金钱31770
- 威望0
- 积分32650