PDA

View Full Version : Accessing form field values with toolbar button handler



NMFord
7 Jan 2012, 12:31 PM
EDIT: I figured out how to access the fields in the controller using getValues(), but I want to be able to access them from the button handler, how do I do that?

I'm a newbie and still learning the framework so sorry for what probably is a simple question.

I've done quite a bit of searching on the forums, google and stackoverflow and can't find an answer to my question.

I have a formpanel and I'm trying to access the the form field values in a handler for the save button so I can send the information from the form fields to my codeigniter app.

I have provided the code for the panel below, the handler function for the button is right at the bottom.

I've tried using the getValue() and getValues() methods but can't seem to figure it out.

Any help is appreciated.

Thanks


BioGene.views.SettingsView = Ext.extend(Ext.form.FormPanel, {
scroll: 'vertical',
id:'settingsform',
initComponent: function () {

this.saveButton = new Ext.Button({
text: 'Save',
ui: 'normal',
handler: this.onSaveTap,
scope: this
});

this.topToolbar = new Ext.Toolbar({
title: 'Settings',
items: [
{ xtype: 'spacer' },
this.saveButton
]
});

this.items = [{
xtype: 'fieldset',
title: 'Organism',
centered: true,
items: [{
xtype: 'selectfield',
name: 'organism',
options: [
{text: 'Human', value: 'human'},
{text: 'Mouse', value: 'mouse'},
{text: 'Rat', value: 'rat'},
{text: 'Zebrafish', value: 'zebrafish'},
{text: 'Fruitfly', value: 'fruitfly'},
{text: 'Nematode', value: 'nematode'},
{text: 'Arabidopsis', value: 'arabidopsis'},
{text: 'Yeast', value: 'yeast'}
],
value: getCookie("bg_organism")
}]
}, {
xtype: 'fieldset',
title: 'Genes Per Page',
items: [
{
xtype: 'selectfield',
name: 'genes_per_page',
options: [
{text: '5 Results', value: '5'},
{text: '10 Results', value: '10'},
{text: '25 Results', value: '25'},
{text: '50 Results', value: '50'}
],
value: getCookie("bg_results")
}]
}, {
xtype: 'fieldset',
title: 'References Per Page',
items: [
{
xtype: 'selectfield',
name: 'rifs_per_page',
options: [
{text: '10 Results', value: '10'},
{text: '25 Results', value: '25'},
{text: '50 Results', value: '50'},
{text: '100 Results', value: '100'}
],
value: getCookie("bg_references")
}]
}];

this.dockedItems = [this.topToolbar];

BioGene.views.SettingsView.superclass.initComponent.call(this);
},

onSaveTap: function () {

//Ext.Ajax.request({
// url: 'codeigniter/index.php/search/set_cookies/'+,
//});

Ext.dispatch({
controller: BioGene.controllers.bioGeneController,
action: 'index',
slideDirection: 'down'
});
}

});

mitchellsimoens
9 Jan 2012, 7:25 AM
So the Button is a child of the Toolbar and the Toolbar is an item of the FormPanel correct? So what happens if you do this:


button.up('formpanel')

Does that return the form panel?

NMFord
9 Jan 2012, 8:51 AM
So the Button is a child of the Toolbar and the Toolbar is an item of the FormPanel correct? So what happens if you do this:


button.up('formpanel')

Does that return the form panel?

Not sure where I'm supposed to apply that piece of code, I tried calling the up method on the button in the view and it returned an undefined variable.

Anyways, I just resorted to processing in the controller rather than in the button handler to save myself stress!