code/template/helper/behavior.php
public function validator($config = array())
    {
        $config = new ObjectConfigJson($config);
        $config->append(array(
            'debug'    => \Kodekit::getInstance()->isDebug(),
            'selector' => '.k-js-form-controller',
            'options_callback' => null,
            'options'  => array(
                'ignoreTitle' => true,
                'onsubmit'    => false // We run the validation ourselves
            )
        ));

        $html = '';

        if(!static::isLoaded('validator'))
        {
            $html .= $this->kodekit();
            $html .= '<ktml:script src="assets://js/'.($config->debug ? 'build/' : 'min/').'jquery.validate.js" />';

            static::setLoaded('validator');
        }

        $options   = (string) $config->options;
        $signature = md5('validator-'.$config->selector.$config->options_callback.$options);

        if (!static::isLoaded($signature))
        {
            if ($config->options_callback) {
                $options = $config->options_callback.'('.$options.')';
            }

            $html .= "<script>
            kQuery(function($){
                $('$config->selector').on('k:validate', function(event){
                    if(!$(this).valid() || $(this).validate().pendingRequest !== 0) {
                        event.preventDefault();
                    }
                }).validate($options);
            });
            </script>";

            static::setLoaded($signature);
        }

        return $html;
    }
public function validator($config = array())
    {
        $config = new ObjectConfigJson($config);
        $config->append(array(
            'debug'    => \Kodekit::getInstance()->isDebug(),
            'selector' => '.k-js-form-controller',
            'options_callback' => null,
            'options'  => array(
                'ignoreTitle' => true,
                'onsubmit'    => false // We run the validation ourselves
            )
        ));

        $html = '';

        if(!static::isLoaded('validator'))
        {
            $html .= $this->kodekit();
            $html .= '<ktml:script src="assets://js/'.($config->debug ? 'build/' : 'min/').'jquery.validate.js" />';

            static::setLoaded('validator');
        }

        $options   = (string) $config->options;
        $signature = md5('validator-'.$config->selector.$config->options_callback.$options);

        if (!static::isLoaded($signature))
        {
            if ($config->options_callback) {
                $options = $config->options_callback.'('.$options.')';
            }

            $html .= "<script>
            kQuery(function($){
                $('$config->selector').on('k:validate', function(event){
                    if(!$(this).valid() || $(this).validate().pendingRequest !== 0) {
                        event.preventDefault();
                    }
                }).validate($options);
            });
            </script>";

            static::setLoaded($signature);
        }

        return $html;
    }
public function validator ( $ config = array ( ) ) { $ config = new ObjectConfigJson ( $ config ) ; $ config -> append ( array ( 'debug' => \ Kodekit :: getInstance ( ) -> isDebug ( ) , 'selector' => '.k-js-form-controller' , 'options_callback' => null , 'options' => array ( 'ignoreTitle' => true , 'onsubmit' => false // We run the validation ourselves ) ) ) ; $ html = '' ; if ( ! static :: isLoaded ( 'validator' ) ) { $ html .= $ this -> kodekit ( ) ; $ html .= '<ktml:script src="assets://js/' . ( $ config -> debug ? 'build/' : 'min/' ) . 'jquery.validate.js" />' ; static :: setLoaded ( 'validator' ) ; } $ options = ( string ) $ config -> options ; $ signature = md5 ( 'validator-' . $ config -> selector . $ config -> options_callback . $ options ) ; if ( ! static :: isLoaded ( $ signature ) ) { if ( $ config -> options_callback ) { $ options = $ config -> options_callback . '(' . $ options . ')' ; } $ html .= "<script>
            kQuery(function($){
                $('$config->selector').on('k:validate', function(event){
                    if(!$(this).valid() || $(this).validate().pendingRequest !== 0) {
                        event.preventDefault();
                    }
                }).validate($options);
            });
            </script>" ; static :: setLoaded ( $ signature ) ; } return $ html ; }
Loads the Forms.Validator class and connects it to Kodekit.Controller.Form

@param array|ObjectConfig $config
@return string   The html output
Loads the Forms . Validator class and connects it to Kodekit . Controller . Form