Yii Framework Forum: Capturing Selected Values Of Checkboxlist - Yii Framework Forum

Jump to content

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

Capturing Selected Values Of Checkboxlist CheckboxList of the Form Model Rate Topic: -----

#1 User is offline   darklord 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 17
  • Joined: 01-August 11

Posted 13 July 2013 - 12:31 PM

I am trying to capture the multiple selected values of Yii checkBoxList.

Here is my view code:
  <div class="row">
   <?php echo $form->labelEx($model, 'comfortFeatureIDs', array('class' => 'bold')); ?><br/>
    <?php echo $form->checkboxList($model, 'comfortFeatureIDs', $model->comfortFeatures ); ?> 
    <?php echo $form->error($model, 'comfortFeatureIDs'); ?>
   </div>


In the controller, I can not capture the selected values.
I have tried this with no luck.
 if (isset($_POST['AdBuilderFormOne'])) {
        	
            # collect posted form data and store them in form attributes  	
            $adBuilderFormOne->attributes = $_POST['AdBuilderFormOne'];
			
			# validate if we have received good data 
			if ($adBuilderFormOne->validate()) {
				# process the collected data and redirect the user to Ad Builder Form Two  
				
				# var_dump($adBuilderFormOne->comfortFeatureIDs);
				
				
				var_dump($adBuilderFormOne['comfortFeatureIDs']);
				
				
				
				# set flash message 
			}
		}

I received NULL from comfortFeatureIDs in the controller.
My question is how do I capture the multiple selected values of the checkBoxList.
Please advise!
0

#2 User is offline   darklord 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 17
  • Joined: 01-August 11

Posted 13 July 2013 - 03:35 PM

View Postdarklord, on 13 July 2013 - 12:31 PM, said:

I am trying to capture the multiple selected values of Yii checkBoxList.

Here is my view code:
  <div class="row">
   <?php echo $form->labelEx($model, 'comfortFeatureIDs', array('class' => 'bold')); ?><br/>
    <?php echo $form->checkboxList($model, 'comfortFeatureIDs', $model->comfortFeatures ); ?> 
    <?php echo $form->error($model, 'comfortFeatureIDs'); ?>
   </div>


In the controller, I can not capture the selected values.
I have tried this with no luck.
 if (isset($_POST['AdBuilderFormOne'])) {
        	
            # collect posted form data and store them in form attributes  	
            $adBuilderFormOne->attributes = $_POST['AdBuilderFormOne'];
			
			# validate if we have received good data 
			if ($adBuilderFormOne->validate()) {
				# process the collected data and redirect the user to Ad Builder Form Two  
				
				# var_dump($adBuilderFormOne->comfortFeatureIDs);
				
				
				var_dump($adBuilderFormOne['comfortFeatureIDs']);
				
				
				
				# set flash message 
			}
		}

I received NULL from comfortFeatureIDs in the controller.
My question is how do I capture the multiple selected values of the checkBoxList.
Please advise!



I found the solution at last.
http://www.yiiframew...heckbox-values/
and this codes work for me.
$comfortFeatureIDs = $_POST['AdBuilderFormOne']['comfortFeatureIDs'];
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