and here’s what i got, the default layout and colors dissappeared,
by the way, my cities table and the other 2 doesn’t have a primary key on their tables, they are stand alone…does that has something to do with why my app turned to white just like that after I added the listData ?
One more thing, is cities or Cities a model? Why is called cities? wouldn’t be city? or City? (I recommend you call the model class as their names states as in Windows environment won’t be a problem but in Linux if your class is saved as City.php Yii won’t find it)
How is your table structured (city or cities), just to provide you with a better answer.
Your app “turned to white” because you have some error, some class that doesn’t exist or something like that, turning on error reporting will speed up your debug.
Please check its attributes as the query you do is the most simplest of them all ‘findAll()’, if your attributes are correct (cityID, cityName) I truly don’t know where is the problem.
Instead of
error_reporting(E_ALL);
ini_set(‘display_errors’,1);
Change the error reporting in your php.ini file to E_ALL and restart your web server. I found that in some environments I couldn’t do that from the code.
that ‘City’ inbetween the $model and CHtml, should I replace it with the ‘CityID’ attribute of the Cities model ?
or just leave it like that?, because I’m pulling the cities data from the Cities model and it is a separate model from the script view who’s trying to use this CHtml helper … (i don’t really know how this thing works despite of reading the dropDownList/listData manual )
Here, cityId and citiName shoud be property of cities.
If this too works, then even the dropdownlist should display.
Anyway, if you continue to get simply white page, it means that your error loggin is not set on, and this will slow you down a lot. Invest some time to make it work, it will be very helpful.
I actually checked my php.ini file, all error related stuff is ‘on’ ever since, my YII debug is on, including
the log thing from the main.php file…
this one works, as per the Company model + the it’s City Attribute, it showed a blank text field as expected
<?php echo $form->textField($model,'City'); ?>
this one doesn’t., it showed a white page only
<?php print_r(CHtml::listData(Cities::model()->findAll(),'CityID','CityName'));?>
[code]
I checked my php_error log, this is what I found out
[code]
CActiveRecord->findAll() C:\xampp\htdocs\yii\myapp\protected\views\wsmembersdetails\_form.php:45
Do you actually have a model Cities? If so, could you check its properties?
Can you, in order for us to help you… post its structure as you did with the $model? Don’t worry about masking its name buddy… Here you find only people who wishes to help.
it doesn’t retrieve anything, it still white page.
by the way, my Cities Table has Cities model only, it doesn’t have a CRUD nor Controller generated from gii,
do you think the crud and controller does matter ? or the model alone should be enough to pull datas from that table ?
this is the contents of the cities model ( i masked the real model name )
<?php
/**
* This is the model class for table "Cities".
*
* The followings are the available columns in table 'cities':
* @property integer $CountryID
* @property integer $RegionID
* @property integer $StateID
* @property integer $CityID
* @property string $CityCode
* @property string $CityName
*
* The followings are the available model relations:
*/
class Cities extends CActiveRecord
{
/**
* Returns the static model of the specified AR class.
* @return Cities the static model class
*/
public static function model($className=__CLASS__)
{
return parent::model($className);
}
/**
* @return string the associated database table name
*/
public function tableName()
{
return 'cities';
}
/**
* @return array validation rules for model attributes.
*/
public function rules()
{
// NOTE: you should only define rules for those attributes that
// will receive user inputs.
return array(
array('CountryID, RegionID, StateID, CityID', 'numerical', 'integerOnly'=>true),
array('CityCode', 'length', 'max'=>10),
array('CityName', 'length', 'max'=>50),
// The following rule is used by search().
// Please remove those attributes that should not be searched.
array('CountryID, RegionID, StateID, CityID, CityCode, CityName', 'safe', 'on'=>'search'),
);
}
/**
* @return array relational rules.
*/
public function relations()
{
// NOTE: you may need to adjust the relation name and the related
// class name for the relations automatically generated below.
return array(
);
}
/**
* @return array customized attribute labels (name=>label)
*/
public function attributeLabels()
{
return array(
'CountryID' => 'Country',
'RegionID' => 'Region',
'StateID' => 'State',
'CityID' => 'City',
'CityCode' => 'City Code',
'CityName' => 'City Name',
);
}
/**
* Retrieves a list of models based on the current search/filter conditions.
* @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
*/
public function search()
{
// Warning: Please modify the following code to remove attributes that
// should not be searched.
$criteria=new CDbCriteria;
$criteria->compare('CountryID',$this->CountryID);
$criteria->compare('RegionID',$this->RegionID);
$criteria->compare('StateID',$this->StateID);
$criteria->compare('CityID',$this->CityID);
$criteria->compare('CityCode',$this->CityCode,true);
$criteria->compare('CityName',$this->CityName,true);
return new CActiveDataProvider(get_class($this), array(
'criteria'=>$criteria,
));
}
}
I did your suggestion., the page color went back to normal, but the ‘City’ field is blank (ofcourse)
but the var_dump(Cities::model()->findAll());
is blank too.
ok, the real table name is gg_t_worldareascities and the real model name generated from gii is GgTWorldareascities ( do you think it causes the problem ?, i mean, the real table name got underscores and the generated model from gii doesn’t have )
The table name is not causing the problem, with you have done we have isolated the problem and we know now that there is no problems with your dropdown list but with your findAll()… Now, lets see its SQL.
In order to view the SQL, we are going to activate CWebLogRoute in your config/main.php file:
Then, call again the view above. Remember, we just want to see one line Cities::model()->findAll();, so reduce the amount of code to that line. Execute and check its results.
Importante note: CWebLogRoute is for development process, on production remove it.
I also tried generating another model version wherein, I typed the gg_t as prefix inside the gii prefix box of the model generator…the model generated was Worldareascities…but still same thing happened