Question

I'm learning ExtJS, and I came across two different concepts, that seem logically connected to me.

  1. Model classes can specify custom validation methods on their fields.
  2. Model instances can be loaded into, and retrieved from Forms.

My question is:

  1. Is it possible to have the form use the model's validation setup to validate what the user enters and show realtime feedback?
  2. If the answer to 1 is No, then is there any other way to set up realtime validation in the form?

Thanks

Was it helpful?

Solution

1. Is it possible to have the form use the model's validation setup to validate what the user enters and show realtime feedback?

There is no built-in functionality for model's realtime validating. However, there is better way then using model's validation.

2. If the answer to 1 is No, then is there any other way to set up realtime validation in the form?

Yes, there is.
Form's fields support vtype config (More info can be found here). By default the fields would be validated everytime the fields' value would change (if you want to turn off this behaviour set field's validateOnChange config to false).

Check out docs (the Validation section and the Example usage section) for more info.

OTHER TIPS

  1. As Molecule Man says, there is no built-in functionality for this, however...

  2. This seems to be a commonly required feature (and something that makes Ext JS 4 look a little half-baked), and other people have come up with various solutions:

The first suggestion modifies the Ext.form.field.Base class to allow binding a form field to a Model field, and to validate the form field against validations defined on the form field as well as those defined on the bound Model field.

I'm just about to test the first suggestion, may post an update on how it goes...

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top