Yii Framework Forum: Cgridview Multicomment - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Cgridview Multicomment Rate Topic: -----

#1 User is offline   MarkBrass 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 130
  • Joined: 13-November 13

Posted 12 May 2014 - 08:33 AM

I'm not sure what is the way to do this , so here I ask:

I have a Person model and Event model , and a connection table Person_Event.

The interface that I got now works in the following way:

1. A person is logging in and his id is being send via URL
2. The person is selecting events he is interested in from the cGridView (checkbox column)
3. Writing some comment
4.Pressing send button , and the following create action is being triggered:
public function actionXcreate()
	{
		$model=new Person_Event;

		if(isset($_POST['Person_Event']))
	   {			
			foreach ($_POST['selectedIds'] as $eventId)
			{				
				$pmodel=new Person_Event;
				$pmodel->person_id=$this->_person->id; 	//the id of the person who is logged in		
				$pmodel->attributes=$_POST['Person_Event'];	//the comment			
				$pmodel->event_id = $eventId;		//all the events he checked in the grid		
				if (!$pmodel->save()) print_r($pmodel->errors);				
			}
			$this->redirect(array('site/success'));
		}


So far , all is logical and simple. However , what I end up is that the comment the person wrote is being duplicated to every person_event row in the DB.

I want to put a text box in each row of the grid , and the commnet that will be written there will go to the specific event.

Now , I found this topic http://www.yiiframew...in-admin-panel/
which is kind of helpful , BUT:

I already have a foreach in the action , the one that matches the person's id with the event's id , so how can I put another individual comment for each combo?
0

#2 User is offline   chandran 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 488
  • Joined: 08-October 12
  • Location:Austria

Posted 13 May 2014 - 03:01 AM

Hi,

Get comment with selectedid

For example

$_POST['comment'.selectedid] like this

Then you can read in controller :)
Thanks
chandran nepolean

My own extension:
http://www.yiiframew...sion/ejqueryte/

My wiki
http://www.yiiframew...checkboxcolumn/

If it work dont hesitate to click +1 button
0

#3 User is offline   MarkBrass 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 130
  • Joined: 13-November 13

Posted 13 May 2014 - 09:24 AM

$_POST['comment'.selectedid]


Ok , 2 question:

1. I need the comment and the id as well , it looks like here I'm passing only the comment of the selected id

2. How do I split them with "as" in order to put those 2 in the right places?
0

#4 User is offline   MarkBrass 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 130
  • Joined: 13-November 13

Posted 14 May 2014 - 02:49 AM

What I mean is: I need to pass both the id and the comment from the grid view to the event_id and event_comment.

How can I do it with the as loop?
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users