I can’t figure out how to display the players for each registration in my GridView:
There are 1 or more players per registration and it does not need to be updated, just displayed as raw data ( something like ‘$data->players-first’.’ ‘.’$data->players-last’)
I can link to a separate (already functioning) players GridView to edit inline by the Registration->ID field.
Can someone please help? My code is below:
I have the following tables:
-
Registrations
-
Players (
-
DivisionLevels
-
Divisions - related through DivisionLevels
-
Levels - related through DivisionLevels
Registrations model attributes and relations:
/**
* This is the model base class for the table "registrations".
* DO NOT MODIFY THIS FILE! It is automatically generated by giix.
* If any changes are necessary, you must set or override the required
* property or method in class "Registrations".
*
* Columns in table "registrations" available as properties of the model,
* followed by relations of table "registrations" available as properties of the model.
*
* @property integer $ID
* @property integer $transactionID
* @property integer $divisionLevelID
* @property integer $field
* @property integer $net
* @property integer $team
* @property string $notes
*
* @property Players[] $players
* @property DivisionLevels $divisionLevel
* @property Fields $field0
* @property Transactions $transaction
public function relations() {
return array(
'players' => array(self::HAS_MANY, 'Players', 'registrationID'),
'divisionLevel' => array(self::BELONGS_TO, 'DivisionLevels', 'divisionLevelID'),
'field0' => array(self::BELONGS_TO, 'Fields', 'field'),
'transaction' => array(self::BELONGS_TO, 'Transactions', 'transactionID'),
);
}
My current admin view is this:
<?php $this->widget('ext.booster.widgets.TbExtendedGridView', array(
'id' => 'registrations-grid',
'dataProvider' => $model->search(),
'filter' => $model,
'columns' => array(
'ID',
array(
'name'=>'transactionID',
'value'=>'GxHtml::valueEx($data->transaction)', // change to text search
),
array(
'name'=>'divisionLevelID',
'header'=>'Division',
'value'=>'GxHtml::valueEx($data->divisionLevel->division)',
'filter'=>GxHtml::listDataEx(Divisions::model()->findAllAttributes(null, true)),
),
array(
'name'=>'divisionLevelID',
'header'=>'Level',
'value'=>'GxHtml::valueEx($data->divisionLevel->level)',
'filter'=>GxHtml::listDataEx(Levels::model()->findAllAttributes(null, true)),
),
array(
'name'=>'field',
'value'=>'GxHtml::valueEx($data->field0)',
'filter'=>GxHtml::listDataEx(Fields::model()->findAllAttributes(null, true)),
), // filters appropriately
array(
'name'=>'ID',
'value'=>'GxHtml::valueEx($data->players)',
),
array(
'name' => 'net',
'header' => 'Net',
'class' => 'ext.booster.widgets.TbEditableColumn',
'headerHtmlOptions' => array('style' => 'width:30px'),
'editable' => array(
'type' => 'text',
'url' => $this->createUrl('registrations/editable')
)
),
array(
'name' => 'team',
'header' => 'Team #',
'class' => 'ext.booster.widgets.TbEditableColumn',
'headerHtmlOptions' => array('style' => 'width:30px'),
'editable' => array(
'type' => 'text',
'url' => $this->createUrl('registrations/editable')
)
),
array(
'name' => 'notes',
'header' => 'Notes',
'class' => 'ext.booster.widgets.TbEditableColumn',
'headerHtmlOptions' => array('style' => 'width:30px'),
'editable' => array(
'type' => 'text',
'url' => $this->createUrl('registrations/editable')
)
),
/*
*/
array(
'class' => 'CButtonColumn',
),
),
)); ?>
Registrations Controller for Admin:
public function actionAdmin() {
$model = new Registrations('search');
$model->unsetAttributes();
if (isset($_GET['Registrations']))
$model->setAttributes($_GET['Registrations']);
$this->render('admin', array(
'model' => $model,
));
}