Ref, autoRef, and name
Having worked mostly with the 2.x series of Ext JS, I very much appreciate the ref / autoRef functionality - makes life a lot easier!
However, unless I'm missing something, it's slightly less convenient than it could be due to having no way to scope the names on config objects that translate to DOM elements. For example, say I have a Panel subclass called AddressPanel. I want to have two instances of this on the same page, maybe a BillingAddressPanel and a MailingAddressPanel. They'd have fields like addressLine1, etc. Using ref / autoRef, I'm mostly free of having to worry about ID's. But on the server, I need to know which addressLine1 is which if the form gets submitted.
It's not the horrible to subclass them again or change the name attribute before render using the ref. I'm just wondering if there's a better way or if perhaps work is being done for a future version of Ext JS to scope the name attributes in some way (like maybe the name gets generated as MailingAddress_addressLine1 even though I've said name: addressLine1 in the config)?
Hrm, not sure what you are looking for here...
name is the config you should be using for formfields when they are submitted to the server. ref is unrelated. Could you rephrase your question as maybe I didn't understand it?
Ok, I'll give my explanation another shot.
They are unrelated in that they are used for different things. The ref / autoRef functionality is a convenient replacement to the method of assigning id's at config time. The name attribute is used for form submissions to associate data sent to the server (it can be used for lookup on the client side, too, but this seems like an inferior alternative). However, they are related in that they all involve looking things up by name. Because of this, they are also related in that they can also give you big problems if you have two things with the same name / id / whatever in the same scope.
I think the ref idea is great because it largely obviates the need for id's specified at config time. One of the big benefits of this for reuse is that you could include two instances of the same component exported from the designer on the same page without major problem. However, if I have a component where I have specified the name attributes of children that are form fields at design time, then I cannot have two instances of the same component on the same form. There probably wouldn't be a runtime error on the client side and the HTTP request would happily send both values, but it could be awkward on the server to sort out which was which.
I was just wondering if there was a way now or potentially some way in the future to automatically scope the names that get generated on the DOM elements to avoid this problem. Maybe containers would have an attribute like baseName (for example) and any form fields included in this container get their names prefixed with this name.
Sry if I'm being unclear... like I said, it's not a huge useability deal for me because if I want different names I can just subclass the class that gets generated from the Designer again or create instances of it and change the name attributes on the form fields before the component is rendered. Just curious if there was a better way or if other people had any thoughts on this.
I'd take a typical HTML-like approach. Provide a hidden form field with a different value and/or send an additional url parameter to change what the action is.