Hi all,
I have a form for the Photos model. The Photos model is related to the Stores model like so:
Store Model
public function relations()
{
return array(
'photos' => array(self::HAS_MANY, 'Photo', 'storeId'),
...
Photo Model
public function relations()
{
return array(
'store' => array(self::BELONGS_TO, 'Store', 'storeId'),
);
}
In the Photos form, I am trying to get a dropdown with the list of all the stores like so:
<div class="row">
<?php echo $form->labelEx($model,'storeId'); ?>
[b]<?php echo $form->dropDownList($model,'storeId',
CHtml::listData(Store::model()->findAll(), 'id', 'name'); ?>[/b]
<?php echo $form->error($model,'storeId'); ?>
</div>
What’s happening is that the page rendering breaks down at the bolded line. If I remove the line, the form displays properly. I have a feeling this might be because the store model’s relationship with the photo model, but can’t quite figure out why, or how to fix this.
Can somebody shed some light on what could be happening? Thanks!
Edit: Store instead of Store, as pointed out by Tommy
Edit 2:
I just noticed that if I change it to:
Store::model()->find(), the page is rendered correctly, but the dropdown list is empty!