PDA

View Full Version : Submitting form does not post form fields



paulharv
3 May 2012, 3:56 PM
I have an Ext.form.Panel and I populate its fields dynamically because I don't know ahead of time what fields it needs.

This is the form:



Ext.define("Timesheet.view.TimeEntryForm", {
extend: 'Ext.form.Panel',
xtype: 'timeentryform'
});


In a controller I load the form like this...



...
myListItemTapEventHandler: function(list, index, item, rec, e) {
var dateStore = Ext.getStore('TimeEntries').setProxy({
type: 'jsonp',
url: '/days/'+rec.get('date')
});
// load the store and provide a callback function to stuff with the loaded data
dateStore.load(function(){
var formFields = [];
// loop the data returned from server and
// create a numberfield for each one
Ext.each(this.data.items, function(rec,b,c){
formFields.push({
xtype:'numberfield',
label:rec.get('label'),
value:rec.get('hours')
});
});
// add submit button to the items to be set on the form
formFields.push({
xtype:'button',
text:'Submit',
handler:function(){
// in the handler for the submit button, navigate
// up to the parent form and submit it
this.up("timeentryform").submit({
url:'/days',
method:'post'
});
}
});
// the list that was tapped - navigate up to its
// parent navigation view and push
// on the form, setting the items as defined
// in formFields above...
list.up('timeentrynav').push({
xtype : 'timeentryform',
title : "Hours for "+date,
items:{
xtype:'fieldset',
items : formFields
}
});
});
...


So, all of this renders the form just fine, but when I click the submit button the values are not submitted - in my server log (I'm using Rails) I see parameters has a key of null and value of ""!!!



Started POST "/days" for 127.0.0.1 at 2012-05-03 19:33:16 -0400
Processing by DaysController#create as
Parameters: {"null"=>""}
Completed 200 OK in 5ms (Views: 4.6ms)


Is there something fundamentally flawed in how I'm building the form dynamically?
Any pointers very welcome.

Thanks

paulharv
3 May 2012, 6:52 PM
Posted this in the wrong forum...it was intended for Sencha Touch 2!

sword-it
8 May 2012, 12:32 AM
Hi Paul,

Just breakpoint in your submit method button functionality and check there if you are getting something from your form or not...may be some scope problem. It will be easier if you may provide some lines of code from your submit button functionality...

See you later!!