\SmartFormValidation_jQuery

Provides javascript form validation rules for jQuery's Validation Plugin

A basic example (taken from testXml.php that comes with SmartDatabase):

<script type="text/javascript" src="/cirkuit/includes/js/jquery/core/1.3.2/jquery.min.js"></script>
<script type="text/javascript" src="/cirkuit/includes/js/jquery/plugins/validate/1.9.0/jquery.validate.min.js"></script>
<script type="text/javascript" src="/cirkuit/includes/js/jquery/plugins/validate/1.9.0/additional-methods.min.js"></script>
<script type="text/javascript">
$(function(){
    //validate page properties form
    $("form[name=test7]").validate({
    <?
        require_once(dirname(__FILE__)."/../FormValidation/SmartFormValidation_jQueryValidate.php");
        $formValidation = new SmartFormValidation_jQuery($database);
        $options = $formValidation->GetPluginOptions('Questionare');
    ?>
        rules: <?=json_encode($options['rules'])?>,
        messages: <?=json_encode($options['messages'])?>
    });
});
</script>
<style type="text/css">
    .error{
        background-color:#FFD5D6;
        border:1px dashed #CC0000;
    }
    label.error{
        background:none;
        border:none;
        color: #cc0000;
        font-size: 11px;
        font-weight: bold;
        margin-left: 1em;
    }
</style>

Summary

Methods
Properties
Constants
__construct()
GetPluginOptions()
$Database
No constants found
No protected methods found
No protected properties found
N/A
GetRulesForColumn()
GetMessagesForColumn()
No private properties found
N/A

Properties

$Database

$Database : \SmartDatabase

Type

\SmartDatabase — The Database that the validation rules will be created for

Methods

__construct()

__construct(\SmartDatabase  $Database) : \SmartTable

Constructor

Parameters

\SmartDatabase $Database

The Database that the validation rules will be created for

Returns

\SmartTable

GetPluginOptions()

GetPluginOptions(string  $tableName = null, string  $columnName = null) : array

Returns the jQuery Validation Plugin's options for the given scope as an assoc array of formObjectName=>array(pluginOption=>value)

Parameters

string $tableName

[optional] If set, returns ALL rules for the given $tableName OR optionally only the rule for the given $columnName

string $columnName

[optional] If set, returns the rule for the given $columnName within the given $Table

Returns

array —

All rules in the database OR optionally all rules for the given $tableName OR optionally only the rule for the given $columnName within the given $tableName

GetRulesForColumn()

GetRulesForColumn(object  $Column) : string

Returns the 'rules' for the given column

Parameters

object $Column

Returns

string —

Javascript for the 'rules' options of the jquery validation plugin

GetMessagesForColumn()

GetMessagesForColumn(object  $Column) : string

Returns the 'messages' for the given column. messages correspond to rules above

Parameters

object $Column

Returns

string —

Javascript for the 'messages' options of the jquery validation plugin