PDA

View Full Version : record.set with object



primolan
4 Apr 2011, 6:35 AM
Hello!

I was trying to use record.set with form.getForm().getValues() (wich return an object) and after reading the manual discovered that record.set do not accept objects.

The solution is simple and I was wondering why this method do not accept object like most other methods do.

In my case, here is the code:



fields = me.form.getForm().getValues();
for(field in fields) {
me.record.set(field, fields[field]);
}


Well, I just wanted to share this with all of you. Thanks!

mankz
4 Apr 2011, 11:09 AM
Easier:



form.getForm().updateRecord(me.record);

primolan
4 Apr 2011, 3:17 PM
Hello Mankz!

Thank you for your attention. Although the manual indicates the use of the create method to create subclasses of Record, Record I instantiate directly, using the recovered values ??of the form as data. The only problem is directly instantiate that there are no definitions of the fields, which is necessary for the updateRecord method.

My way is easier because it does not need to specify the fields on the other hand end up having to use foreach to apply the necessary sets.

Thank you!