i can´t get the dropDownList, what am i doing wrong?
My model Dir.php
<?php
/**
* This is the model class for table "tbl_dir".
*
* The followings are the available columns in table 'tbl_dir':
* @property integer $id
* @property string $d_codigo
* @property string $d_asenta
* @property string $d_mnpio
* @property string $d_estado
* @property string $c_estado
* @property string $c_mnpio
*/
class Dir extends CActiveRecord
{
/**
* Returns the static model of the specified AR class.
* @return Dir 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 'tbl_dir';
}
/**
* @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('d_codigo, d_asenta, d_mnpio, d_estado, c_estado, c_mnpio', 'required'),
array('d_codigo, d_asenta, d_mnpio, d_estado', 'length', 'max'=>50),
array('c_estado, c_mnpio', 'length', 'max'=>5),
// The following rule is used by search().
// Please remove those attributes that should not be searched.
array('id, d_codigo, d_asenta, d_mnpio, d_estado, c_estado, c_mnpio', '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(
'id' => 'ID',
'd_codigo' => 'D Codigo',
'd_asenta' => 'D Asenta',
'd_mnpio' => 'D Mnpio',
'd_estado' => 'D Estado',
'c_estado' => 'C Estado',
'c_mnpio' => 'C Mnpio',
);
}
/**
* 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('id',$this->id);
$criteria->compare('d_codigo',$this->d_codigo,true);
$criteria->compare('d_asenta',$this->d_asenta,true);
$criteria->compare('d_mnpio',$this->d_mnpio,true);
$criteria->compare('d_estado',$this->d_estado,true);
$criteria->compare('c_estado',$this->c_estado,true);
$criteria->compare('c_mnpio',$this->c_mnpio,true);
return new CActiveDataProvider(get_class($this), array(
'criteria'=>$criteria,
));
}
}
My model empresa.php
<?php
/**
* This is the model class for table "tbl_empresa".
*
* The followings are the available columns in table 'tbl_empresa':
* @property integer $id
* @property string $empresa
* @property string $rfc
* @property string $domicilio
* @property string $colonia
* @property integer $cp
* @property string $mun_del
* @property string $estado
* @property string $fecha_ingreso
*/
class Empresa extends SolinforActiveRecord
{
/**
* Returns the static model of the specified AR class.
* @return Empresa 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 'tbl_empresa';
}
/**
* @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('empresa, rfc', 'unique'),
array('empresa, rfc, domicilio, colonia, cp, mun_del, estado', 'required'),
array('cp', 'numerical', 'integerOnly'=>true),
array('empresa, domicilio, colonia, mun_del, estado', 'length', 'max'=>100),
array('rfc', 'length', 'max'=>13),
array('rfc', 'length', 'min'=>11),
array('cp', 'length', 'min'=>5),
// The following rule is used by search().
// Please remove those attributes that should not be searched.
array('id, empresa, rfc, domicilio, colonia, cp, mun_del, estado', '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(
'id' => 'ID',
'empresa' => 'Nombre de la Empresa',
'rfc' => 'Rfc',
'domicilio' => 'Calle y Número',
'colonia' => 'Colonia',
'cp' => 'Codigo Postal',
'mun_del' => 'Delegación o Municipio',
'estado' => 'Estado',
'fecha_ingreso' => 'Fecha Ingreso',
);
}
/**
* 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('id',$this->id);
$criteria->compare('empresa',$this->empresa,true);
$criteria->compare('rfc',$this->rfc,true);
$criteria->compare('domicilio',$this->domicilio,true);
$criteria->compare('colonia',$this->colonia,true);
$criteria->compare('cp',$this->cp);
$criteria->compare('mun_del',$this->mun_del,true);
$criteria->compare('estado',$this->estado,true);
$criteria->compare('fecha_ingreso',$this->fecha_ingreso,true);
return new CActiveDataProvider(get_class($this), array(
'criteria'=>$criteria,
));
}
}
My _form.php
<div class="row">
<?php
echo $form->labelEx($model,'colonia');
i change this line
[b]
echo $form->dropDownList(
$model,
'colonia',
CHtml::listData(Dir::model ()->findAll('id>1'),'id','d_asenta')
);
[/b]
echo $form->error($model,'colonia');
?>
</div>
Any help will be appreciate