PDA

View Full Version : [CLOSED]Automatic form record update



dolittle
16 Apr 2011, 7:36 PM
It is possible to assign a record to a form using:

form.loadRecord(record);
and later get the record from the form and update it:

var record = form.getRecord();
var values = form.getValues();
record.set(values);

I suggest three improvements to this API:

1. autoUpdateRecord config option on the form that when set to true automatically updates the record and keep the record and the form in sync.
2. autoSyncRecord/Store config option on the form that when set to true automatically saves the record (or sync the store) when submitting the form (if it is valid).
3. Auto for fields from a model. Similar to how django let you create a form from a model automatically. You'll just need to define the record and the fields will be created for you. The user can override a model field explicitly in the form to get custom functionality.

evant
19 Apr 2011, 10:06 AM
We have a ticket open internally to improve form/model binding.

JorisA
6 May 2011, 8:01 AM
Great! It would also be awesome to be able to apply the model's validators to the form.