Hi there,
I'm currently stuck with creating a functional activeCheckBoxList in my form view.
The fallowing code does work for the create view, but unfortunately, it doesn't work for the update view. Let me explain a little about the setup: I want to show a 'checkboxlist' so users can select more than one category. Yii threw me this error when i navigated to the 'update' action:
Quote
Model (Article.php)
<?php
public function relations()
{
return array(
'author'=>array(self::BELONGS_TO, 'User', 'authorId'),
'comments'=>array(self::HAS_MANY, 'Comment', 'articleId',
'order'=>'??.createdOn ASC'),
'categories'=>array(self::MANY_MANY, 'Category','news_article_category(articleId, categoryId)',
'order'=>'name'),
'categoryFilter'=>array(self::MANY_MANY, 'Category', 'news_article_category(articleId,categoryId)',
'together'=>true,
'joinType'=>'INNER JOIN',
'condition'=>'??.name=:category'),
);
}
?>
View (_form.php)
<ul><?php echo CHtml::activeCheckboxList(
$article,
'categories',
CHtml::listData(
Category::model()->findAll(),
'id',
'name'
),
array(
'template'=>'<li>{input} {label}</li>',
)
); ?></ul>
As you can see, i used listData to create the array for the label and value of checkboxes. This works in article/create, but it doesnt in article/update
Does someone have a clue for this? Thank you