Say I have a form with one field such as below, then how do I add a addition value to the form values, so its passed in the submit() call (as commented below):
Code:
Ext.define("test.view.AddCommentForm", {
extend: 'Ext.form.Panel',
xtype: 'addcommentform',
requires: [
'Ext.form.TextArea',
'Ext.field.Hidden'
],
config: {
title: 'Add Comment',
url: 'backend/add_comment.php',
scrollable: false,
items: [
{
xtype: 'fieldset',
title: 'Add Comment',
items: [
{
xtype: 'textareafield',
name: 'comment',
label: 'Comment',
labelWidth: 150,
placeHolder: '',
required: true,
margin: 20,
}
]
},
{
id: 'button-send',
xtype: 'button',
text: 'Send',
ui: 'confirm',
handler: function() {
var to_user_id = 50; // how do I add this to the form values, so they get passed in the submit call below, without having to add it to the item list above?
var values = this.up('addcommentform').getValues();
if (!values.comment)
{
Ext.Msg.alert('Add Comment', 'Please enter your comment');
}
else if (!values.to_user_id) // clearly this will not work until the above variable to_user_id is added to the values
{
Ext.Msg.alert('Add Comment', 'No user selected');
}
else
{
this.up('addcommentform').submit({
success: function(form, result) {
Ext.Msg.alert('Add Comment', 'Added comment successfully');
form.reset();
},
failure: function(form, result) {
Ext.Msg.alert('Add Comment', 'An error occurred, please try again later');
}
});
}
}
}
]
}
});