PDA

View Full Version : Submiting an Form problem



msuchwalko
12 Jun 2012, 5:26 AM
Hello,

I would like to ask for some help please. I am trying to submit form with filefields. Doing it like in tutorials, but my app dont want to work with me.

In controler i have such function

saveProduct: function(button) { var form = button.up('form').getForm();
if(form.isValid()){
form.submit({
disableCaching : true,
timeout: 5,
scope: this,
url: 'api.php/dodaj_produkty.json',
waitMsg: 'Uploading your photo...',
success: function(Form, action) {
Ext.Msg.alert('Ze niby sukceasdsads');
},
failure: function(fp, o) {
Ext.Msg.alert('Not success');
}
});
}
}

My form:

Ext.define('Santi.view.Product.NewProductForm', { extend: 'Ext.form.Panel',
alias: 'widget.productform',
autoHeight: true,
width: '100%',
border: 0,
initComponent: function() {
this.items = [
{
xtype: 'fieldset',
plain: true,
frame: true,
border: 0,
bodyPadding: 5,
defaults: {
xtype: 'textfield',
labelWidth: 130,
inputType: 'text',
anchor: '50%',
selectOnFocus: true,
required: true
},
items: [
{
itemId: 'name',
fieldLabel: Ext.i18n.appBundle.getMsg('productForm.name'),
name: 'name'
},
{
xtype: 'checkboxgroup',
fieldLabel: Ext.i18n.appBundle.getMsg('productForm.available_size'),
columns: 3,
vertical: true,
items: [
{
boxLabel: 'XS',
name: 'item_size',
inputValue: '0'
},
{
boxLabel: 'S',
name: 'item_size',
inputValue: '1'
},
{
boxLabel: 'M',
name: 'item_size',
inputValue: '2'
},
{
boxLabel: 'L',
name: 'item_size',
inputValue: '3'
},
{
boxLabel: 'XL',
name: 'item_size',
inputValue: '4'
},
{
boxLabel: 'XXL',
name: 'item_size',
inputValue: '5'
},
{
boxLabel: 'one-size',
name: 'item_size',
inputValue: '6'
}
]
},
{
xtype: 'textareafield',
itemId: 'description',
fieldLabel: Ext.i18n.appBundle.getMsg('productForm.description'),
name: 'description',
grow : true,
anchor : '60%'
},
{
xtype: 'filefield',
id: 'photo1',
name: 'photo1',
fieldLabel: Ext.i18n.appBundle.getMsg('productForm.photo')+' 1',
msgTarget: 'side',
allowBlank: true,
anchor: '60%',
buttonText: Ext.i18n.appBundle.getMsg('productForm.photo_select'),
validator: this.isPicture


},
{
xtype: 'filefield',
name: 'photo2',
fieldLabel: Ext.i18n.appBundle.getMsg('productForm.photo')+' 2',
msgTarget: 'side',
allowBlank: true,
anchor: '60%',
buttonText: Ext.i18n.appBundle.getMsg('productForm.photo_select'),
validator: this.isPicture
},
{
xtype: 'filefield',
name: 'photo3',
fieldLabel: Ext.i18n.appBundle.getMsg('productForm.photo')+' 3',
msgTarget: 'side',
allowBlank: true,
anchor: '60%',
buttonText: Ext.i18n.appBundle.getMsg('productForm.photo_select'),
validator: this.isPicture
},
{
xtype: 'button',
type: 'reset',
text: Ext.i18n.appBundle.getMsg('productForm.reset'),
handler: function() {
this.up('form').getForm().reset();
},
region: 'east',
anchor: '20%',
margin: '20 0 0 10'
}
]
}
];

this.callParent(arguments);
},
setDefaultValue: function() {
var me = this.me;
var combo = me.down('combobox[name=client_type_id]');
combo.setValue(this.client_type_id);
},
isPicture: function() {
if(this.getValue().length == 0){
return true;
}
var imageRegex = /(\.|\/)(gif|jpe?g|png|bmp)$/i;
if(this.getValue().match(imageRegex) == null) {
return Ext.i18n.appBundle.getMsg('productForm.photo_invalid');
}
else {
return true;
}
}
});

And in PHP

public function executeAdd(sfWebRequest $request) { $this->getResponse()->setContentType('text/json');
$result['success'] = false;
$result['error']['clientCode'] = "Client not found";
return $this->renderText(json_encode($result));


}

Thing is no data seems to be POSTED. In firefox status that controller returns is always succesfull submit message. No firebug errors. In chrome uploading freeze in waitMSG and in Console i get some sort of recurention: interface/interface/interface/interface/interface/designer.html (http://santi.michal.extreme-develing.org/interface/api.php/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/interface/designer.html) 403 (Forbidden)

And that recurention is longer

Do u guys have any idea what I do wrong? Looking forward any response. Ty

scottmartin
12 Jun 2012, 7:55 AM
Can you verify your header is correctly sending the data, the server has received the data and it exists in the table and is sending back the correct data at the server and as a response?

Scott.