Hello all,
I am just starting with Yii application development and stuck with an issue for which I couldn’t find any solution. Here is my case:
I have two entities in the application which are created as two modules in Yii: Organization and Contact.
The Organization can have any number of Contacts and it’s linked through the field org_id in Contacts table. (I didn’t used Foreign Key relationships to avoid complexity and this application needs to be deployed in a MyISAM database.)
One of the requirements in the application is that in the Organization VIEW page,the user should be able to see a list of contacts(with pagination) associated with the Organization. The user should be able to get into the Contact view/edit from the Organization View page.
I implemented this in the following fashion:
In modules/organization/controllers/DefaultController.php
public function actionView($id)
{
$this->render('view',array(
'model'=> Organization::get($id),
'contactProvider' => Contact::getContactsByOrg($id),
));
}
In modules/organization/views/default/view.php
<?php $this->widget('zii.widgets.grid.CGridView', array(
'id'=>'users-grid',
'dataProvider'=>$contactProvider,
'columns'=>array(
'contact_name',
'org_name',
'category_name',
'status',
'modified_by_name',
'modified_time',
array(
'class'=>'CButtonColumn',
),
),
)); ?>
However, the links generated for the paging, viewing and editing Contacts actually points to Organization instead of Contact. As a result, sorting and paging doesn’t work properly. How can I change the URL in the Contact list?