activeCheckBoxList question

When using an activeCheckBoxList how should the data be stored in the database if they select multiple checkboxes?

I see that it comes through as an array, but to show the checkboxes being checked in the update, how does the activeCheckBoxList need the values stored?



You can serialize/deserialize it in beforeSave()/afterFind()

great, thanks.

Just to help out the newbies to Yii like me, this is what I did to store multiple checkboxes in my db table. There may be a better way to handle this, but it works.

In the model I added the beforeSave() method with the following:

  public function beforeSave()


	$paymentArr = $this->paymentAmt;

	$paymentList = "";

	$counter = 0;

	  for ($i=0; $i<count($paymentArr); $i++) {


	   $paymentList = $paymentList.$paymentArr[$i];


            if ($counter != count($paymentArr))


            $paymentList = $paymentList.",";




	return parent::beforeSave();


This puts the values from the checkbox list into an actual comma delimited list and stores it in my table.

Then I added this to the afterFind() method:

public function afterFind()


	$this->paymentAmt = split(",",$this->paymentAmt);

	return parent::afterFind();