PDA

View Full Version : Multiple Singleton Form using item with same id



Florynth
25 Sep 2007, 5:10 PM
Hi,

I want to use forms as singleton so I got differents forms for different model (database table). For the mapping of the form fied I use the name and id who are the same and the value is set in function of the table colum

Exemple (did take out some text but just figure taht a ManagementPanel is a form)

[PHP]LaBottinEntityManagementPanel.add(
new Ext.form.TextField({
id: 'section',
fieldLabel: 'Section',
name: 'section',
width:175,
allowBlank:false
}),

new Ext.form.TextField({
id: 'departement_id',
fieldLabel: 'D

evant
25 Sep 2007, 5:30 PM
ID's should be unique, there's no real way around it.

Florynth
25 Sep 2007, 5:44 PM
Their's probably a soution since when you add some node to a tree the id is no use for the element but just as a reference. I think node could have same Ids if they are in a different tree.

evant
25 Sep 2007, 5:52 PM
http://www.w3.org/TR/html4/struct/global.html#h-7.5.2

Florynth
25 Sep 2007, 6:31 PM
I know all my XHTML and DOM rule... that's not the point

Node in a tree are pass a ID who's not use in the dom element but only as a reference for Ext...

I'm wondering if there's a solution for this for form field in the add option.

evant
25 Sep 2007, 7:07 PM
I'm not going to bother posting the whole trace, but if you track from field.js up to component.js, you'll see that if you specify an id, that element will be rendered with that id to the DOM.

Florynth
26 Sep 2007, 3:00 AM
In the tree I did do a inspect with Firebug and I did found anything around the node using the Id I did pass... maybe I didn't check properly...

evant
26 Sep 2007, 4:01 AM
You're talking about a form, not a tree, they act differently.

Florynth
26 Sep 2007, 4:23 AM
That's my point ! I would like the Id of a field to be manage like a Id of a tree node. :D

evant
26 Sep 2007, 4:30 AM
I know that you'd like that, but as I said earlier, it doesn't appear to be possible with Ext at the moment, so you will either have to
a) Modify Ext
b) Come up with your own solution

Florynth
26 Sep 2007, 2:59 PM
It's not exactly what I've done but it's the concept who's important



MyForm = function (config)
{
MyForm.superclass.constructor.call(this,config);
}

Ext.extend(MyForm,Ext.form.Form,{
add : function()
{
for(var i = 0 ; i < arguments.length ; i++)
{
item = arguments[i];
item.id = item.id != undefined ? item.id : item.name + Ext.id();
}
Ext.form.Form.prototype.add.apply(this, arguments);
}

});