PDA

View Full Version : Query about sending values to server



robert6000
14 Sep 2008, 8:06 AM
Hi

I've got FormPanel like on a first attachement. On this FormPanel is also hidden element which contains names of checked checkboxes written in some format for example: ' B2-P3-P5-S1-S4'. When I do submit on my form,


this.form.getForm().submit({url: 'result.php'});

there are sent values (second attachement) to the server. Because I have my hiddenField on my form I don't need to send names of my checked checkboxes to server.

My question is: Is it possible to block in any way some of the form fields that won't be sent to the server on the submit action?

Robert.

14 Sep 2008, 8:54 AM
the only way to do it is to intercept override the form's getValues method and delete those references.

I say just leave them.

Animal
14 Sep 2008, 8:57 AM
Inputs with a blank name attribute are not submitted, so if you collect the references to the inputs, and clear the name, they won't get submitted.

robert6000
14 Sep 2008, 9:24 AM
Thanks a lot!

14 Sep 2008, 9:30 AM
Inputs with a blank name attribute are not submitted, so if you collect the references to the inputs, and clear the name, they won't get submitted.

I'm confused:


var win = new Ext.Window({
width : 400,
height : 400,
items : {
xtype : 'form',
items : [
{
xtype : 'textfield',
name : ''
}
,{
xtype : 'textfield',
name : ''
}
]

}

});
win.show();

(function() {
console.log(win.items.items[0].form.getValues());
win.items.items[0].form.submit({
url : 'test',
success : function() {
}

});
}).defer(50);

yields :
http://tdg-i.com/img/screencasts/2008-09-14_1329.png

Animal
14 Sep 2008, 9:41 AM
I think there's an Ext bug in there somewhere.

If you look at the generated document, the inputs have a name.

14 Sep 2008, 9:43 AM
yeah, i didn't digest what you were saying earlier. I see what you mean now :P

tidalbobo
14 Sep 2008, 10:14 AM
@Animal,
I also agree with your earlier post. If no 'name' is provided, a form will not submit that particular value ( as it is sent in name=value pairs)
What happens is ( im guessing), Ext must be providing a default name for any element that is not explicitly named.
I would not call is a 'bug' though...

@robert6000
a small suggestion to your matter...
Have the checkboxs out of the form. Have only the hidden field in the form.



makeStringOfCheckboxes();
this.form.getForm().submit({url: 'result.php'});
What makeStringOfCheckboxes() should do is, see what checkboxes are 'checked' and build the ' B2-P3-P5-S1-S4' and put in the hidden field (which is on the form). So on submit, it will be sent.



function makeStringOfCheckboxes(){
//pseudo code
//hold the return value
strList = "";
get list of check boxes
for each checlbox in list
if checked
strList = strList + "-" + checkBox_Name

set strList to the hidden fields value
return strList;
}
Keep us updated.