Ext 4: Validating a Form with a Model

hi team and community,

this is meant as a constructive feedback topic and a discussion about a feature request.
when i first saw the news for ext 4, telling me validations inside a model, i thought "cool", i can create multiple forms and just have to specify the rules at one spot.

I'm not sure if this can be transformed to work with "addCustomer" (i.e. blank form on initialisation), but if I edit a selected customer (or system user in my case) from a grid it seems to work.

What I do (before editing a user):
- a gridpanel lists all users and of the course, the bound store has a Model
- select a user from the grid and I hit my edit button
- a form is generated and from the edit button click listener I use "form.loadRecord(record_from_grid_with_grids_selectionModel)"

This should bind an empty record to the form and after the user edited the form, BasicForm can use the existing empty Record, update the data fields in the record with the fieldvalues and perform the validation on the record.

Hopefully, this is understandable

Your suggestion sound like a solid solution (model config option in form).
But with MVC the form is only a visual representation of a Record and the Controller (in your example the button handler) should worry which model is used and validated against the "visual representation".

Appreciate your clear and gracefully way of proposing optimization to the framework

Having validations in one place

To me the important issue is that validation is business logic, and views shouldn't be aware of business logic. Also, in the majority of cases creating models in the GUI, to me makes no sense. Only when your app is really the Ext app, it makes sense. But in a normal server client situation, the business logic should reside on the server side. Otherwise it defies the MVC pattern.

Therefore, I have a validator that just loads a model from the server and the server returns how the model should be validated like:

Code:

{

"success": true,

-
-
"data": [

-
-
{

"Name": "ImportDto",

-
-
"Props": [

-
-
{

"Name": "GStandDbName",

-
-
"Validations": [

-
-
{

"Type": "min",

-
-
"Arguments": [

"2"

]

}

]

},

-
-
{

"Name": "GStandDbPassword",

"Validations": [ ]

},

-
-
{

"Name": "GStandDbServer",

"Validations": [ ]

},

-
-
{

"Name": "GStandDbUser",

"Validations": [ ]

},

-
-
{

"Name": "GStandDirectory",

-
-
"Validations": [

-
-
{

"Type": "directory",

"Arguments": [ ]

}

]

},

-
-
{

"Name": "RavenDbName",

"Validations": [ ]

},

-
-
{

"Name": "RavenDbPassword",

"Validations": [ ]

},

-
-
{

"Name": "RavenDbUrl",

-
-
"Validations": [

-
-
{

"Type": "url",

"Arguments": [ ]

}

]

},

-
-
{

"Name": "RavenDbUser",

"Validations": [ ]

}

]

}

],

"total": 1,

"message": ""

}

The validator takes the model description an applies the validations to the form like this: