ExtJS: form validation against model

jrharshath picture jrharshath · Sep 4, 2011 · Viewed 10.2k times · Source

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

Answer

Oliver Coleman picture Oliver Coleman · Jan 6, 2012
  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...