PDA

View Full Version : Checkbox doesn't see inputValue



spmorlowski
8 Dec 2014, 10:55 PM
Hey guys there.
I've got annoying thing. Everythings work pretty well and one day....


var myForm = new Ext.form.Panel({ standardSubmit: false,
defaultType: 'checkbox',
autoScroll: true,
defaults: {labelWidth: 250},
items:[{
fieldLabel: 'Some field',
name: 'MyCheckbox',
id: 'MyCheckbox',
padding: '0 0 0 5',
inputValue: 'T'
}]
});


alert(Ext.getCmp('MyCheckbox').value);


myForm.submit({
url: 'my/example/url',
scope: this,
method: 'POST',
success: function(){
//TODO
},
});

I've got this code and alert and also form submit get "true" or "false" from checkbox instead "T". I didn't change anything in my code. Would someone can help me?


EDIT: Now I also see in inspector that this checkbox with inputValue attribute don't have any value="" in HTML. Anyone can know what about?

aaugen
9 Dec 2014, 1:17 AM
Hi spmorlowski,

Try to get your inputValue with method: getSubmitValue (http://docs.sencha.com/extjs/4.2.3/#!/api/Ext.form.field.Checkbox-method-getSubmitValue)() (http://docs.sencha.com/extjs/4.2.3/#!/api/Ext.form.field.Checkbox-method-getSubmitValue).
Acccording to API, it seems normal to not get the value 'T' in 'value' property when the inputValue property is used.

spmorlowski
9 Dec 2014, 1:19 AM
I will try but I didn't get anything... Just form.submit - and it's all... And it worked.

EDIT: Ok... I checked it and getSubmitValue() returns "T". So what should I do to return "T" by form.submit({}); ? I need it... I've got a lot of checkboxes, so using form.submit would be really so helpful...

spmorlowski
10 Dec 2014, 12:02 AM
bump please.

aaugen
10 Dec 2014, 12:33 AM
Hi,

I tried a similar example on Ext JS API "Live Preview" with version 4.2.3 and it works well.
After the submit method, the request object contain tree parameters including "MyCheckbox" with 'T' value when I select this checkbox.



Ext.create('Ext.form.Panel', {
title: 'Simple Form',
bodyPadding: 5,
width: 350,

// The form will submit an AJAX request to this URL when submitted
url: 'save-form.php',

// Fields will be arranged vertically, stretched to full width
layout: 'anchor',
defaults: {
anchor: '100%'
},

// The fields
defaultType: 'textfield',
items: [{
fieldLabel: 'First Name',
name: 'first',
allowBlank: false
},{
fieldLabel: 'Last Name',
name: 'last',
allowBlank: false
},{
xtype: 'checkbox',
fieldLabel: 'Some field',
name: 'MyCheckbox',
id: 'MyCheckbox',
padding: '0 0 0 5',
inputValue: 'T'
}],

// Reset and Submit buttons
buttons: [{
text: 'Reset',
handler: function() {
this.up('form').getForm().reset();
}
}, {
text: 'Submit',
formBind: true, //only enabled once the form is valid
disabled: true,
handler: function() {
var form = this.up('form').getForm();
if (form.isValid()) {
form.submit({
success: function(form, action) {
Ext.Msg.alert('Success', action.result.msg);
},
failure: function(form, action) {
Ext.Msg.alert('Failed', action.result.msg);
}
});
}
}
}],
renderTo: Ext.getBody()
});


what is your framework version?

spmorlowski
10 Dec 2014, 3:46 AM
A few hours ago I also tried some example by online sencha fildder and it wokred to.
I'm using Sencha 4.2.1.883 with Symfony 2.

Judging by working online example and fact that everything was good a few days ago I can suspect that somethings wrong with my sencha files... I don't want to replace all files. Should I replace just ext-all-debug.js? Or maybe it isn't good way to make it work...?

spmorlowski
10 Dec 2014, 11:08 PM
I replaced ext-all.js and nothing's changed... I really have no idea why it doesn't send inputValue...Anyone...?