How can I set a date to NULL in Yii?

后端 未结 3 817
生来不讨喜
生来不讨喜 2020-12-15 07:22

I have a date column that usually takes values as dd.MM.yyyy. Its validation rule in the model\'s rules() is this:

array(\'start, e         


        
3条回答
  •  有刺的猬
    2020-12-15 07:44

    The trivial fix for this is not to set the value at all during creation:

    if (!empty($csv_data)) {
      $user->start = $csv_data;
    }
    

    This way, the date will not be set and thus appear as empty, which also passes validation.

提交回复
热议问题