In-Portal Issue Tracker

Welcome to the In-Portal Open Source CMS Issue Tracker! This is a central management / tracking tool for all types of tasks / issues / bugs for the In-Portal Project. Before reporting any issues, please make sure to read the Guide into Issue Tracker and How to Properly Test and Report Bugs!

Dependency Graph View Issue ] Relation Graph ] Vertical ]
related to child of duplicate of

Viewing Issue Simple Details
ID Category Type Reproducibility Date Submitted Last Update
0000271 [In-Portal CMS] Data Management feature request N/A 2009-09-04 15:28 2012-07-25 05:32
Reporter alex View Status public  
Assigned To alex
Priority normal Resolution fixed  
Status closed      
Summary 0000271: Redesign "Data Validation" Engine
Description Here is form data processing cycle from user to database:

1. user opens editing template and inputs form data into form fields;
2. user presses save button to place it's changes to database;
3. form data is passed to kDBItem (or it's descendant) class for processing;
4. class kDBItem (or it's descendant) uses kDBItem::Validate method to validate data before saving to database;
5. internally validation is performed using options defined for each field in it's declaration (all fields are validated, no matter what fields were submitted from form);
6. based on validation results user is either returned to form with validation errors displayed or editing window is successfully closed.

This approach has several not obvious weaknesses:
1. all fields are validated, instead of submitted only fields - this takes time, when not all possible fields are displayed on form;
2. validation rules are defined directly in field declaration in unit config - this doesn't allow form-based validation rules on base level (but can be done inside event handler as usual).

Idea is to move all validation-related field options to form declaration (see task 0000270) and submit used form name along with form fields to kDBItem class, that will use it to perform form-based validation.

How to do this:
1. create kValidator class (with one public method named ValidateField) and move all validation-related code to it from kDBItem class;
2. add $form_name parameter to kDBItem::Validate and to kDBItem::ValidateField methods;
3. when $form_name parameter is not passed, then create (and cache) instance of kValidator class and use validation-related options from field declaration in unit config;
4. when $form_name parameter is passed, then create (and cache) instance of validator class, specified in form declaration and use validation-related options for given field from form declaration;
5. validate form fields using appropriate validator class and validation-related options.
4. create ValidatorClass unit config option (like ListClass option), that will allow to define custom validator class for given unit config and use it later in forms declared inside that unit config.

This way compatibility with unit configs, that don't use forms, layouts will be preserved. Also side effect is, that less memory will be used, when data from several tables in displayed on same screen (front-end mostly).
Additional Information Form Usage:
===========
You can define as many forms as you need in 'Forms' unit config option, e.g.

'Forms' => Array (
    'front_registration' => Array (
        'Fields' => Array (
            'FirstName' => Array ('required' => 1, 'default' => ''),
        )
    ),
),

In this example new form called 'front_registration' is created. Database field called 'FirstName' is made required on this form. If form called 'default' is also defined, then it is always applied first.


You can override following unit config options from form declaration:
- ItemSQLs
- ListSQLs
- Fields
- CustomFields
- VirtualFields
- CalculatedFields
- AggregatedCalculatedFields


1. to set form name in template use this tag <inp2:prefix.special_FormName name="front_registration"/> before any other tag of this prefix.special.

2. to pass form-name to next template after form submit place this hidden field on a form:
<input type="hidden" name="forms[prefix.special]" value="<inp2:prefix.special_FormName/>"/>

3. to use custom validator class do this:
- add 'ValidatorClass' => 'CustomValidator' to unit config
- register class in factory



Web Development by Intechnic
In-Portal Open Source CMS
In-Portal Open Source CMS
Copyright © 2000 - 2009 MantisBT Group

Powered by Mantis Bugtracker