Hi
I have two tables
-
student (studentId, name, student_rId)
-
registration (rId, regNumber)
Student_rId and rId is an entity relation of one is to one nature
I have used Crud to generate code
I am facing trouble to show in student view
student.studentId, student.name, registration.regNumber
My code looks as below
<?php $this->widget(‘bootstrap.widgets.TbGridView’,array(
'id'=>'student-grid',
'dataProvider'=>$model->Search(),
'filter'=>$model,
'columns'=>array(
'studentId',
'name',
'student_rId',
array(
'class'=>'bootstrap.widgets.TbButtonColumn',
),
),
)); ?>

Keith
(Kburton)
2
Assuming that CRUD has set up relations for you, then you should be able to access the values from the other table using the relation. Something like:
'relationName.studentId',
I’d guess the relation name would be student in your case, so try ‘student.studentId’
No CRUD has not generated any relation code
I tried below code in relation of student model
‘studentReg’ => array(self::HAS_ONE, ‘registration’, ‘rId’)
and used
studentReg.regNumber
in TBGridView.array(…
…
‘columns’=>array(
‘studentId’,
‘studentReg.regNumber’,
…
…
but not getting table content displayed
correct me where I am going wrong
Thanks for helping …
JFReyes
(Jose Reyes)
4
Try
array(
'name'=>'Registration',
'value'=>'$data->studentReg->regNumber',
),