<?php
$state = State::model();
$countries = Country::model()->findAll();
$htmlOptions = array();
foreach($countries AS $country ) {
$states = $state->findByAttributes(array('country_id' => $country->id));
// $list = CHtml::listData($states, 'id', 'name');
$options = CHtml::listOptions('', $states, $htmlOptions);
// print_r($options); exit;
}
echo CHtml::dropDownList('name', null, $options);
?>
ERROR :
PHP notice : Trying to get property of non-object
states.php
there is a dropdownlist (states)in a form, when we click the state name,it has been show with the country details that are present in the country table.
thanks