2013-08-20 3 views
1

내 모델에 세 개의 새 필드 (년, 월, 일)를 추가했습니다. 양식을 제출할 때 데이터가 채워지지 않습니다. 모든 세 가지 사용자 정의 속성은 제출시 null입니다.Yii의 양식 제출시 사용자 정의 필드가 null입니다.

I have asked this question before 단일 속성에 대한 여러 필드를 구현할 때 나는 대답을 제안했습니다. 어떻게해야합니까? 여기 내 코드가있다.

사용자 모델 :

class User extends CActiveRecord 
{ 
    public $month; 
    public $year; 
    public $day; 
    ... 

보기 파일 :

<?php echo $form->labelEx($model, "dob"); ?> 
<?php echo $form->dropDownList($model, 'year', $model->getDobOptions('year')); ?> 
<?php echo $form->dropDownList($model, 'month', $model->getDobOptions('month')); ?> 
<?php echo $form->dropDownList($model, 'day', $model->getDobOptions('day')); ?> 

답변

3

당신은뿐만 아니라 안전뿐만 해당 필드를 설정하는 기억나요?

public function rules() { 
    return array(
     array('month, year, day', 'safe'), 
    ... 

당신이하지 않으면,이하지 않습니다 컨트롤러의 모델 형태의 값을 통해 '사본'

$model->attributes = $_GET['User']; 
+0

오, 그래. 나는 잊어 버렸다 ... –