-
14 Dec 2012 4:12 AM #1
Unanswered: How to define get/setName methods on form field with Panel as a component?
Unanswered: How to define get/setName methods on form field with Panel as a component?
Hi,
I'm using Signature Pad Field and the problem is that while it extends from field.Text, is uses Panel as its component:
The issue with it is that when I call form.getValues(), value of signature field is not returned, as it doesn't have name value. I can get it "manually" by finding signature field and calling getValue on it, but it would be more convenient, if it worked just like the rest of fields.Code:Ext.define('ux.signaturefield', { extend: 'Ext.field.Text', xtype : 'signaturefield', config: { component: { xtype: 'panel' } } });
I can't set name value like this:
because Sencha calls setName method on a component, which in this case is a Panel instance that doesn't have such method. I tried this:Code:{ xtype: "signaturefield", name: "signature" }
but it didn't defined getter and setter methods for name attribute on panel component.Code:Ext.define('ux.signaturefield', { extend: 'Ext.field.Text', xtype : 'signaturefield', config: { component: { xtype: 'panel', name: null } } });
Any tips how to do it?
-
14 Dec 2012 5:01 AM #2
Not sure if this will work, otherwise you should try to extend panel and use that as component for the signaturefield:
Code:Ext.define('ux.signaturefield', { extend: 'Ext.field.Text', xtype : 'signaturefield', config: { component: { xtype: 'panel', config: {name: null} } } });
-
14 Dec 2012 5:15 AM #3
Thanks, I've already tried it as well

If extending Panel is the only way - is it ok to define 2 classes in a single file? I'd like to keep the Signature Field extension in a single file.
[EDIT]: Creating a custom panel with name attribute inside signaturefield.js file and using it as a component instead of a plain panel works (at least in the browser). It's still strange that specifying name attribute when specifying form field component config doesn't create getters/setters. Not sure if it's a bug or is it supposed to work like that.
-
29 Dec 2012 10:18 PM #4
Just override set updateName function inside the plugin
Just override set updateName function inside the plugin
You can see, that text field will try to match component ( what is a panel in our case). What you need to do, is inside plugin insert:
where you set name to text field instead of Panel.Code:updateName: function(newName) { debugger; this.setName(newName); },
Hope that helps.
Nick


Reply With Quote