array('date_from, date_to', 'date', 'format'=>'yyyy-mm-dd', 'allowEmpty' => true, 'message'=>'date(y-m-d) are mandatory',),
yang ane butuh date_from lebih kecil(<) dari date_to,, gimana ya cara nya?
Posted 08 May 2012 - 11:39 PM
array('date_from, date_to', 'date', 'format'=>'yyyy-mm-dd', 'allowEmpty' => true, 'message'=>'date(y-m-d) are mandatory',),
Posted 09 May 2012 - 04:46 AM
array('date_from, date_to', 'validDate' )
public function validDate($attribute, $params)
{
if($this->date_from < $this->date_to)
{
$this->addError('date_to',' '.$this->date_to.' harus lebih besar dari '.$this->date_from);
//return false;
}
}
Posted 09 May 2012 - 04:54 AM
array('date_from, date_to', 'validDate' )
public function validDate($attribute, $params)
{
$date_1 = $this->date_from; //buat tanggal format yyyy-mm-dd
$date_2 = $this->date_to; //buat tanggal format yyyy-mm-dd
list($year, $month, $day) = explode('-', date_1);
$new_date_1 = sprintf('%04d%02d%02d', $year, $month, $day);
list($year, $month, $day) = explode('-', date_2);
$new_date_2 = sprintf('%04d%02d%02d', $year, $month, $day);
if ($date_2 < $date_1) {
$this->addError('date_to',' '.$this->date_to.' harus lebih besar dari '.$this->date_from);
}
}
Posted 09 May 2012 - 10:31 PM
teguh11, on 09 May 2012 - 04:54 AM, said:
array('date_from, date_to', 'validDate' )
public function validDate($attribute, $params)
{
$date_1 = $this->date_from; //buat tanggal format yyyy-mm-dd
$date_2 = $this->date_to; //buat tanggal format yyyy-mm-dd
list($year, $month, $day) = explode('-', date_1);
$new_date_1 = sprintf('%04d%02d%02d', $year, $month, $day);
list($year, $month, $day) = explode('-', date_2);
$new_date_2 = sprintf('%04d%02d%02d', $year, $month, $day);
if ($date_2 < $date_1) {
$this->addError('date_to',' '.$this->date_to.' harus lebih besar dari '.$this->date_from);
}
}
array('date_from','compare','compareAttribute'=>'date_to','operator'=>'<', 'message'=>'Date_from must be less than Date_To'),
Posted 09 May 2012 - 11:21 PM
kfahmi, on 09 May 2012 - 10:31 PM, said:
array('date_from','compare','compareAttribute'=>'date_to','operator'=>'<', 'message'=>'Date_from must be less than Date_To'),
Posted 22 May 2012 - 10:16 AM
public function monthly($month,$limit)
{
$this->getDbCriteria()->mergeWith(array(
'condition' => 'tanggal=:tanggal',
'params' => array(':tanggal' => $month),
'limit'=>$limit,
));
return $this;
}