Jump to content
Larry Ullman's Book Forums
melaniecarr23

Cgridview By Attributes

Recommended Posts

I have been using the Yii Book to create an admin module for a site I didn't create that uses the yii framework.

 

I was able to successfully create the module, apply login functionality to it, and implement Yii booster for extendedgrid functionality with inline editing.

 

I can link the text from a column using the foreign key relation to a different model's view (primary key) and display those results using the TbExtendedGridView.  What doesn't seem to work for me is displaying the results according to a different attribute other than the primary key.

 

Link:

http://mysites.com/index.php?r=admin/registrations/adminlinked&id=29

http://mysites.com/index.php?r=admin/registrations/divisionLevel&id=3

 

RegistrationController:

public function actionAdminLinked($id)
	{
	     $model = $this->loadModel($id, 'Registrations');

			$this->performAjaxValidation($model, 'registrations-form');

			if (isset($_POST['Registrations'])) {
				$model->setAttributes($_POST['Registrations']);

				if ($model->save()) {
					$this->redirect(array('view', 'id' => $model->ID));
				}
			}

			$this->render('adminlinked', array(
					'model' => $model,
					));

	}
	public function actionDivisionlevel($id)
	{
	    $model=Registrations::model()->with('divisionLevel','division','level','players')->findAllByAttributes(array(
		    'divisionLevelID'=>$id,
));

			$this->performAjaxValidation($model, 'registrations-form');

			$this->render('adminlinked', array(
					'model' => $model,
					));

	}

Note: I'd like to add the ability to display player names (2 to 4 depending on the registration), division and level names (through divisionLevel relations).

 

actionAdminLinked displays results correctly.

actiondivisionLevel displays a blank screen.

 

What on earth am I doing wrong that I can't seem to get this to work?  I've tried for hours.

Share this post


Link to post
Share on other sites

I figured out what I was doing wrong.  I now just use the admin.php view for both, but with different controller actions.

public function actionAdminLinked($id)
	{
	    $model = new Registrations('search');

		if (isset($_GET['Registrations']))
			$model->setAttributes($_GET['Registrations']);
			$model->ID = $id;

		$this->render('admin', array(
			'model' => $model,
		));

	}
	public function actionDivisionlevel($id)
	{
		$model = new Registrations('search');

		if (isset($_GET['Registrations']))
			$model->setAttributes($_GET['Registrations']);
			$model->divisionLevelID = $id;

		$this->render('admin', array(
			'model' => $model,
		));

	}

I still don't know how to display the many players for each registration in the GridView, if anyone has a clue please help!

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...