PDA

View Full Version : Form's JsonReader mapping



gianpaulo
22 Feb 2010, 8:03 PM
I have a FormPanel configuration that looks like this (please ignore the custom xtypes) :



var config = {
frame:true,
bodyStyle:'padding:5px 5px 0',
width:500,
reader:new Ext.data.JsonReader({
root:'data',
record:'data',
successProperty:'success',
fields:[
{name:'data[TimeInOut][employee_id]',mapping:'TimeInOut.employee_id'},
{name:'data[TimeInOut][date]',mapping:'TimeInOut.date'},
{name:'data[TimeInOut][time_in1]',mapping:'TimeInOut.time_in1'},
{name:'data[TimeInOut][time_out1]',mapping:'TimeInOut.time_out1'},
{name:'data[TimeInOut][time_in2]',mapping:'TimeInOut.time_in2'},
{name:'data[TimeInOut][time_out2]',mapping:'TimeInOut.time_out2'},
{name:'data[TimeInOut][time_in3]',mapping:'TimeInOut.time_in3'},
{name:'data[TimeInOut][time_out3]',mapping:'TimeInOut.time_out3'},
{name:'data[TimeInOut][time_in4]',mapping:'TimeInOut.time_in4'},
{name:'data[TimeInOut][time_out4]',mapping:'TimeInOut.time_out4'},
{name:'data[TimeInOut][time_in5]',mapping:'TimeInOut.time_in5'},
{name:'data[TimeInOut][time_out5]',mapping:'TimeInOut.time_out5'}
]
}),
items:[
{xtype:'HRIS.Commons.EmployeeChooser',fieldLabel:'Employee',name:'data[TimeInOut][employee_id]',hiddenName:'data[TimeInOut][employee_id]'},
{xtype:'datefield',fieldLabel:'Date',name:'data[TimeInOut][date]'},
{xtype:'HRIS.LoginLogout.TimeInOutField',fieldName1:'data[TimeInOut][time_in1]',fieldName2:'data[TimeInOut][time_out1]'},
{xtype:'HRIS.LoginLogout.TimeInOutField',fieldName1:'data[TimeInOut][time_in2]',fieldName2:'data[TimeInOut][time_out2]'},
{xtype:'HRIS.LoginLogout.TimeInOutField',fieldName1:'data[TimeInOut][time_in3]',fieldName2:'data[TimeInOut][time_out3]'},
{xtype:'HRIS.LoginLogout.TimeInOutField',fieldName1:'data[TimeInOut][time_in4]',fieldName2:'data[TimeInOut][time_out4]'},
{xtype:'HRIS.LoginLogout.TimeInOutField',fieldName1:'data[TimeInOut][time_in5]',fieldName2:'data[TimeInOut][time_out5]'}
],
buttons:[{
text:'Submit',handler:function(){
this.form.getForm().submit();
}
}]
}


And here's a sample json data it's consuming:



{"success":true,"total":1,"data":{"TimeInOut":{"id":"3","employee_id":"391","date":"2005-07-26","time_in1":"00:00:00","time_out1":"00:00:00","time_in2":null,"time_out2":null,"time_in3":null,"time_out3":null,"time_in4":null,"time_out4":null,"time_in5":null,"time_out5":null}}}


For some reason I do not know, it's not loading the data to the form as expected. I'm using CakePHP on the server side. Any kind of help would be appreciated.

gianpaulo
23 Feb 2010, 5:12 PM
up!

bclinton
23 Feb 2010, 5:20 PM
edited: incorrect advice