HTML_QuickForm、日付のチェック

<?php
require_once( 'HTML/QuickForm.php' );

define( '_SELECT_ERROR', '%sを選択してください。' );
define( '_VALID_ERROR', '正しい%sを入力してください。' );
define( '_AS_YOU_LIKE', 3 );

class MyForm extends HTML_QuickForm
{
    function MyForm()
    {
        parent::HTML_QuickForm();
        $this->registerElementType( 'date_jp', 
                                    '/path/to/jp.php', 
                                    'HTML_QuickForm_date_jp' );
    }

    function addDate( $name, $label )
    {
        $option = array(
            'minYear'          => date( 'Y' ) - _AS_YOU_LIKE, 
            'maxYear'          => date( 'Y' ) + _AS_YOU_LIKE, 
            'format'           => 'Y 年 m 月 d 日',
            'addEmptyOption'   => true,
            'emptyOptionValue' => '',
            'emptyOptionText'  => '--'
        );
        
        $default = array(
            $name => array( 
                'Y' => date( 'Y' ), 
                'm' => date( 'm' ), 
                'd' => date( 'd' ),
                'H' => date( 'H' ), 
                'i' => '0'
            )
        );
        
        $this->addElement( 'date_jp', $name, $label, $option );
        $this->setDefaults( $default );
        
        $this->addGroupRule( $name, sprintf( _SELECT_ERROR, $label ), 'required' );
                                   
        $this->registerRule( 'isValidDate', 'callback', '_isValidDate', $this );
        $this->addRule( $name, sprintf( _VALID_ERROR, $label ), 'isValidDate', true );
    }
    
    function _isValidDate( $vals )
    {
        if ( checkdate( $vals['m'], $vals['d'], $vals['Y'] ) ) {
           
           return true;
        }
        
        return false;
    }
}
?>