apologies if this has been covered before but I couldn''t find it in the archives. naming a form field using the convention "object_name[attribute_name]" makes life very easy for us but it''s not valid xhtml. an element''s name attribute can''t contain square brackets. does anyone have a workaround? alan
Why do you think it isn''t valid XHTML? Looking at the XHTML strict DTD we see: <!ATTLIST input %attrs; %focus; type %InputType; "text" name CDATA #IMPLIED ...>(and similarly for all other form elements) - ie. name is defined as holding CDATA, which means it can take any literal string as a value Hadley
From the XHTML 1.0 Spec, Section C.8: In XML, URI-references [RFC2396] that end with fragment identifiers of the form "#foo" do not refer to elements with an attribute name="foo"; rather, they refer to elements with an attribute defined to be of type ID, e.g., the id attribute in HTML 4. Many existing HTML clients don''t support the use of ID-type attributes in this way, so identical values may be supplied for both of these attributes to ensure maximum forward and backward compatibility (e.g., <a id="foo" name="foo">...</a>). Further, since the set of legal values for attributes of type ID is much smaller than for those of type CDATA, the type of the name attribute has been changed to NMTOKEN. This attribute is constrained such that it can only have the same values as type ID, or as the Name production in XML 1.0 Section 2.3, production 5. Unfortunately, this constraint cannot be expressed in the XHTML 1.0 DTDs. Because of this change, care must be taken when converting existing HTML documents. The values of these attributes must be unique within the document, valid, and any references to these fragment identifiers (both internal and external) must be updated should the values be changed during conversion. Note that the collection of legal values in XML 1.0 Section 2.3, production 5 is much larger than that permitted to be used in the ID and NAME types defined in HTML 4. When defining fragment identifiers to be backward-compatible, only strings matching the pattern [A-Za-z][A-Za-z0-9:_.-]* should be used. See Section 6.2 of [HTML4] for more information. Am 09.04.2005 um 15:50 schrieb hadley wickham:> Why do you think it isn''t valid XHTML? > > Looking at the XHTML strict DTD we see: > > <!ATTLIST input > %attrs; > %focus; > type %InputType; "text" > name CDATA #IMPLIED > ... >> > (and similarly for all other form elements) > > - ie. name is defined as holding CDATA, which means it can take any > literal string as a value > > Hadley > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
> Note that the collection of legal values in XML 1.0 Section 2.3, > production 5 is much larger than that permitted to be used in the ID > and NAME types defined in HTML 4. When defining fragment identifiers > to be backward-compatible, only strings matching the pattern > [A-Za-z][A-Za-z0-9:_.-]* should be used. See Section 6.2 of [HTML4] > for more information.So the use of something[] is against _recommendation_ (not mandated) in order to ensure backwards compatibility. Thankfully, Rails is not pushing any new ground as the same style is used in PHP. Hence, everyone and their dog will forever adhere to do the right thing on this or tons of PHP websites would stop working. As such, the problem appears to be one of no practical importance. -- David Heinemeier Hansson, http://www.basecamphq.com/ -- Web-based Project Management http://www.rubyonrails.org/ -- Web-application framework for Ruby http://www.loudthinking.com/ -- Broadcasting Brain
True. Am 09.04.2005 um 16:05 schrieb David Heinemeier Hansson:>> Note that the collection of legal values in XML 1.0 Section 2.3, >> production 5 is much larger than that permitted to be used in the ID >> and NAME types defined in HTML 4. When defining fragment identifiers >> to be backward-compatible, only strings matching the pattern >> [A-Za-z][A-Za-z0-9:_.-]* should be used. See Section 6.2 of [HTML4] >> for more information. > > So the use of something[] is against _recommendation_ (not mandated) > in order to ensure backwards compatibility. Thankfully, Rails is not > pushing any new ground as the same style is used in PHP. Hence, > everyone and their dog will forever adhere to do the right thing on > this or tons of PHP websites would stop working. > > As such, the problem appears to be one of no practical importance. > -- > David Heinemeier Hansson, > http://www.basecamphq.com/ -- Web-based Project Management > http://www.rubyonrails.org/ -- Web-application framework for Ruby > http://www.loudthinking.com/ -- Broadcasting Brain > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >