PDA

View Full Version : Form with Buttons in the Modern toolkit



wbabich
1 Jul 2015, 12:50 PM
Does anybody have a working example of a FormPanel that contains a text field and a button, and when you press the button it submits the form including the text in the field?
I'm trying to do this in the Modern toolkit, and all the examples I've found don't work.
There is, for example, no "button" config on a formpanel in the Modern toolkit.

Thank you

joel.watson
1 Jul 2015, 1:50 PM
Hi--

Sure, you should be able to add a button to your form, and then in the handler for the button (or a listener to the tap event), call submit() on the form.

Please see the fiddle below for an example.

https://fiddle.sencha.com/#fiddle/pp3

Hope that helps! Thanks
Joel

wbabich
2 Jul 2015, 5:58 AM
Thank you Joel.
My problem was that I was trying to use "listeners" instead of "handler", and the documentation is incorrect.

Documentation for "listeners" at http://docs.sencha.com/extjs/6.0/6.0.0-modern/#!/api/Ext.form.Panel-cfg-listeners should say:

click: {
element: 'element', // "element", not "el"
fn: function(){ console.log('click el'); }
},

joel.watson
2 Jul 2015, 6:28 AM
Thank you Joel.
My problem was that I was trying to use "listeners" instead of "handler", and the documentation is incorrect.

Documentation for "listeners" at http://docs.sencha.com/extjs/6.0/6.0.0-modern/#!/api/Ext.form.Panel-cfg-listeners should say:

click: {
element: 'element', // "element", not "el"
fn: function(){ console.log('click el'); }
},

Thanks for pointing that out.

You can also so a listener for the tap event like so:


{
xtype: 'button',
text: 'Submit Form',
listeners: {
tap: function(btn, e) {
... submit form...
}
}
}