-
Type: Feature Request
-
Status: Closed
-
Priority: Minor
-
Resolution: Fixed
-
Affects Version/s: 5.1.0
-
Fix Version/s: 5.2.0-B1
-
Component/s: Data Management
-
Labels:
-
External issue URL:
-
Additional information:
-
Story Points:3
-
External issue ID:271
-
Copy Issue Key:
-
Patch Instructions:
Here is form data processing cycle from user to database
- user opens editing template and inputs form data into form fields;
- user presses save button to place it's changes to database;
- form data is passed to kDBItem (or it's descendant) class for processing;
- class kDBItem (or it's descendant) uses kDBItem::Validate method to validate data before saving to database;
- 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);
- 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
- all fields are validated, instead of submitted only fields - this takes time, when not all possible fields are displayed on form;
- 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 INP-226) 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
- create kValidator class (with one public method named ValidateField) and move all validation-related code to it from kDBItem class;
- add $form_name parameter to kDBItem::Validate and to kDBItem::ValidateField methods;
- 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;
- 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;
- validate form fields using appropriate validator class and validation-related options.
- 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).
- relates to
-
INP-765 User isn't automatically logged-in, when "Immediate" user registration mode is used
- Closed
-
INP-225 "Form Layout" Configurator for Add/Edit Templates in Admin
- New
-
INP-226 "Form Configuration" for Add/Edit in Admin Console
- New
-
INP-291 Remove "kDBEventHandler::RemoveRequiredFields" method
- Closed
-
INP-895 Error messages are displayed on unrelated forms
- Closed