朋友们,
我有一个包含几个项目的注册表单,这些项目的下拉列表似乎没有被表单提交选中。
风景:
</div>
<div class="row">
<?php echo CHtml::activeLabel($model, 'Gjinia'); ?>
<?php echo CHtml::dropDownList('sex', 0, $data = array(0 => 'Mashkull', 1 => 'Femer'))
?>
</div>
<div class="row">
<?php echo CHtml::activeLabel($model, 'Arsimimi'); ?>
<?php echo CHtml::dropDownList('education', 0, $data = array(0 => 'Ulet', 1 => 'Mesem', 2 => 'Larte')) ?>
</div>
<div class="row">
<?php echo CHtml::activeLabel($model, 'Statusi Martesor'); ?>
<?php echo CHtml::dropDownList('marital_status', 0, $data = array(0 => 'Beqar/e', 1 => 'I/E divorcuar', 2 => 'I/E martuar', 3 => 'I/E veje')) ?>
</div>
验证规则:
public function rules() {
// NOTE: you should only define rules for those attributes that
// will receive user inputs.
return array(
array('name, lastname, sex, education,
marital_status, employment,
dob, municipality, address,
cell_no, email, initialPassword,
repeatPassword', 'required'),
array('sex, employment, municipality,', 'numerical', 'integerOnly' => true),
array('email, initialPassword, repeatPassword, name, lastname', 'length', 'max' => 100),
array('initialPassword, repeatPassword', 'required', 'on' => 'insert'),
array('initialPassword, repeatPassword', 'length', 'min' => 6, 'max' => 40),
array('initialPassword', 'compare', 'compareAttribute' => 'repeatPassword'),
);
}
提交表单后,当我在 $_POST['Auser'] 上执行 print_r 时,我得到以下信息:
Array ( [name] => Name [lastname] => Lname [address] => B ellit
[cell_no] => 044 568 178 [email] => gzzi@gmail.com [id] => [sex] =>
[education] => [marital_status] => [employment] => [industry] => [dob] =>
[municipality] => [password] => )
和错误信息:
Sex cannot be blank.
Education cannot be blank.
Marital Status cannot be blank.
Employment cannot be blank.
Dob cannot be blank.
Municipality cannot be blank.