how doe i call the loadCity() function located in de CityController.php from out of the actionEdit.php.
if i do an echo in de loadCity() it wil not displays. so the function is never called. the page wil not display an error
thank you
Filestructure:
private_html --application ----controller ------city --------actionEdit.php ------CityController.php --framework public_html -- index.php
actionEdit.php
<?php
class actionEdit extends CAction
{
public function run()
{
//grab city
$row = $this->getController()->loadCity(); //how to call this method
//render view
$this->getController()->render('edit', array('city' => $row));
}
}
CityController.php
<?php
class CityController extends CController
{
public $_city;
/**
* Declares class-based actions.
*/
public function actions()
{
return array(
'index' => 'application.controllers.city.actionList',
'edit' => 'application.controllers.city.actionEdit',
);
}
public function loadCity($id = NULL)
{
if ($this->_city === NULL)
{
if ($id !== NULL || isset($_GET['id']))
{
$this->_city = Citi::model()->findbyPk($id !== NULL) ? $id : $_GET['id'];
}
}
return $this->_city;
}
}