i'm developing a site. i built a for for upload images according a section id. i put the following:
<?php echo $form->labelEx($model,'Seccion'); ?>
<?php echo $form->dropDownList($model,'id_seccion',array(1=>"Inicio", 2=>"Nuestra Empresa", 3=>"Servicios", 4=>"Productos", 5=> "Nuestros Clientes")); ?>
<?php echo $form->error($model,'seccion'); ?>
at the moment to send the form, i get an error
Quote
Seccion cannot be blank.
in the same web site, following the post sample in the tutorial, the same thing works.
setting the tables and relations as made for yii i have:
for post model
/**
* @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(
'author' => array(self::BELONGS_TO, 'User', 'author_id'),
'seccion' => array(self::BELONGS_TO, 'Seccion', 'id_seccion'),
);
}
for banner model
/**
* @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(
'seccion' => array(self::BELONGS_TO, 'Seccion', 'id_seccion'),
);
}
in the rules i have:
for post
return array(
array('title, content, status, id_seccion', 'required'),
array('status, id_seccion, create_time, update_time, author_id', 'numerical', 'integerOnly'=>true),
array('title', 'length', 'max'=>128),
array('tags', 'safe'),
// The following rule is used by search().
// Please remove those attributes that should not be searched.
array('id, title, content, tags, status, id_seccion, create_time, update_time, author_id', 'safe', 'on'=>'search'),
);
for banner
return array(
array('imagen, id_seccion', 'required'),
array('id_seccion', 'numerical', 'integerOnly'=>true),
// this will allow empty field when page is update (remember here i create scenario update)
array('imagen', 'file','types'=>'jpg, gif, png', 'allowEmpty'=>true, 'on'=>'update'),
// The following rule is used by search().
// Please remove those attributes that should not be searched.
array('id_banner, id_seccion', 'safe', 'on'=>'search'),
);
my question is: why i get that validation error in id_seccion if in post model works fine?

Help













