Re: HTML_QuickForm2_Node: ID generation

From: Date: Tue, 04 May 2010 08:16:37 +0000
Subject: Re: HTML_QuickForm2_Node: ID generation
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-30494@lists.php.net to get a copy of this message
Hi Christian, On 03.05.2010 23:04, Christian Weiske wrote:
Element IDs have to be specified explicitly in the attributes array, otherwise they are autogenerated - with an index appended to them: Element named "username" gets ID "username-0". While this makes sense for large and complicated forms, it is not really convenient for small forms with no duplicated element names. How am I supposed to get "pretty" IDs automatically? Overwriting generateID() is not really possible, since I would have to do that for every single element class.
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. Anyway, I probably still have an alternative implementation of generateId() laying around somewhere, it uses element name as default and only appends indexes if necessary.

« previous php.pear.general (#30494) next »