Prev: HTML_QuickForm2_Renderer_Array: Element IDs as array key?
Next: HTML_QuickForm2_Renderer: ArrayAccess
From: Alexey Borzov on 13 May 2010 05:57 Hi, On 04.05.2010 16:29, Christian Weiske wrote: >>> Autogenerating such IDs was Bertrand's idea (CCing him), I was >>> actually in favor of your approach. There probably were some good >>> reasons, but I can't quite remember them, hopefully Bertrand will >>> be able to shed some light here. >> >> It makes the element id more predictable than having "username" and >> then "username-1". It also simplify javascript code in case you have >> to deal with element ids. For example, it is more consistent and >> easier to write : var id = "username-" + i; than : >> var id; >> if (i == 0) { >> id = "username"; >> } else { >> id = "username-" + i; >> } >> It also makes regex matching on elements id faster and easier, CSS3 >> will support basic regex selectors IIRC. And it reduces your chances >> to break your own code since you know what to expect all the time, be >> there one or many elements. I think you have to get used to it to >> start to see the benefit, I admit it doesn't look "pretty" at first. > > I see the benefits of that system - for complex forms. > >> We could also propose a way to override Node::generateId(), it's just >> a static function, it could be replaced by any php callback, ids are >> stored in a static variable as well : >> Node::useIdGenerator('generateMyId') > That's something that would be really, really cool and helpful. > Maybe a form attribute? I've committed a change to ID generation: generateId() method now uses 'id_force_append_index' configuration option to check whether it should always append indexes or do it for duplicate elements only. Thus if you do HTML_Common::setOption('id_force_append_index', false); you get the desired behavior. I don't think we really need a way to completely replace generateId(), especially since that method uses protected class variables.
From: Alexey Borzov on 13 May 2010 05:58 Hi, On 13.05.2010 13:57, Alexey Borzov wrote: > Thus if you do > HTML_Common::setOption('id_force_append_index', false); > you get the desired behavior. Should be HTML_Common2::setOption('id_force_append_index', false); of course.
From: Christian Weiske on 26 May 2010 13:19 Hi Alexey, > > Thus if you do > > HTML_Common::setOption('id_force_append_index', false); > > you get the desired behavior. > Should be > HTML_Common2::setOption('id_force_append_index', false); > of course. Great! Works fine here. -- Regards/Mit freundlichen GrüÃen Christian Weiske -=â¡ Geeking around in the name of science since 1982 â¡=-
First
|
Prev
|
Pages: 1 2 Prev: HTML_QuickForm2_Renderer_Array: Element IDs as array key? Next: HTML_QuickForm2_Renderer: ArrayAccess |