Yii Framework Forum: Controller does not have a method named "getDirections" - Yii Framework Forum

Jump to content

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

Controller does not have a method named "getDirections" relational Rate Topic: -----

#1 User is offline   bas_vdl 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 215
  • Joined: 01-April 09

Posted 29 October 2009 - 08:09 AM

Hello guys, i'm not sure if this is a bug or just a mis understanding of the API by myself.

i try to make my table headings sortable. But i get the error: Controller does not have a method named "getDirections".

be aware of the normal sort on Daytrip and the relation sort of City.

thank you in advance.

Model:
public function relations()
{
    return array(
        'rCity' => array(self::BELONGS_TO, 'City', 'CityId', 'alias' => 'rCity'),
    );
}


View:
<?php echo CSort::link('Daytrip'); ?>
<?php echo CSort::link('rCity.City'); ?>


Controller:
public function actionList()
{
    $criteria = new CDbCriteria;
    
    $withOption = array('rCity', 'rTag');
    
    if(!empty($_GET['q']))
    {
        $criteria->condition = 'Daytrip LIKE "%' . $_GET['q'] . '%"';
        $daytripCount = Daytrip::model()->with($withOption)->count($criteria);
    }
    else
    {
        $daytripCount = Daytrip::model()->with($withOption)->count($criteria);
    }
    
    $sort = new CSort('Daytrip');
    $sort->defaultOrder = 'IdDaytrip ASC';
    $sort->applyOrder($criteria);

    $pages = new CPagination($daytripCount);
    $pages->pageSize = Yii::app()->params['ItemsPerPage'];
    $pages->applyLimit($criteria);

    $daytrips = Daytrip::model()->with($withOption)->findAll($criteria);
    $this->render('list', array('daytrips' => $daytrips, 'pages' => $pages));
}

0

#2 User is offline   qiang 

  • Yii Project Lead
  • Yii
  • Group: Yii Dev Team
  • Posts: 5,899
  • Joined: 04-October 08
  • Location:DC, USA

Posted 02 November 2009 - 07:34 PM

You should call $sort->link() instead of CSort::link().
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