1

私はかなり単純な問題のネット上でさまざまな解決策を試して夢中になっています

私のアプリケーションには文字どおり何百もの日付が保存されており、クライアントのソース データには日付が異なる形式であるという悪い習慣があります。

たとえば、私のモデルの 1 つには次のようなルールがあります (完了するために、この特定のモデルのすべてがリストされています)。

    public function rules() {
        return array(
            array('function, junior, ces,agreement_expected,start_date', 'required'),
            array('start_budget', 'numerical'),
            array('visa_received,training_days', 'numerical', 'integerOnly' => true),
            array('function, junior, ces,currency', 'length', 'max' => 10),
            array('agreement_received, status, stop_date_original, stop_date_extended', 'safe'),
            array('agreement_received,  visa_received, stop_date_original, stop_date_extended', 'default', 'setOnEmpty' => true, 'value' => null),
            array('agreement_received,agreement_expected,start_date,stop_date_original,stop_date_extended', 'date', 'format' => 'Y-m-d', 'allowEmpty' => true),
            array('id, Sname,PFces, PFdomain,PDkeyword, PFstatus, PRname,PRcountry,PRscore,PRcomment,PRngo,TRname,TRpic, TFfunction, TFx, TRdateofbirth,TRedufields,TRcoach,TRlocation,TRtask,TRcontract,TRproject,TRcontact,TFdateofbirth,TFedufields,TFcoach,TFlocation,TFtask,TFcontract,TFproject,TFcontact, 
date1,date2,idate, ddomains,dkeywords,country,agreement, function,ngo, status,group, junior, junior_lastname, junior_firstname,search_all,search_interrupt, ces, agreement_expected, agreement_received, visa_received, start_date, stop_date_original, stop_date_extended,currency, start_budget, training_days', 'safe', 'on' => 'search'),
        );
    }

私が達成したいことは、次のルールによって描かれています

        array('agreement_received,  visa_received, stop_date_original, stop_date_extended', 'default', 'setOnEmpty' => true, 'value' => null),
        array('agreement_received,agreement_expected,start_date,stop_date_original,stop_date_extended', 'date', 'format' => 'Y-m-d', 'allowEmpty' => true),

フォームがあり、たとえば stop_date_extended で空の値を送信すると、NULL ではなく空の文字列に設定されます。

私は何を間違っていますか?確かに、日付バリデータを使用しないとピーチが機能するため、簡単な回避策が必要です。

4

2 に答える 2