Re: [Zope3-dev] zope.app.form generates invalid HTML

2007-02-23 Thread Martin Aspeli



Tres Seaver wrote:
 
 I'm pretty sure you're not allowed dots in ids of HTML elements.
 
 The attached HTML and XHTML pages both pass the W3C validator (one HTMl
 4.01 strict, the other XHTML 1.0 strict).  Both use dotted IDs for form
 elements.  Neither renders properly in Firefox 1.5 (the selectors
 based on the dotted ID, as well as those based on attribute, don't get
 applied the form elements).
 
 At 
 least not when they are prefixed by 'form'. A zope.schema.TextLine in a 
 formlib form, for example, generates HTML like this:
 
input id=form.title class=textType type=text value=Changed 
 title size=20 name=form.title/
 
 In particular, we want to style the fields to look a bit more like 
 Plone, and we have special cases for title and description that we 
 want to style by ID, not class.
 
 However, CSS like this has no effect in Firefox or Safari:
 
 #form.title {
  font-size: 160%;
  font-family: dtml-var headingFontFamily;
  font-weight: normal;
  width: 99%;
 }
 #form.description {
  font: 100% dtml-var fontFamily;
  font-weight: bold;
  height: 6em;
  width: 99%;
 }
 
 Not all that surprising - it could look like I'm styling a form with 
 class=description.
 
 Not according to the CSS specs.  Note that we might be better off making
 it easy to place a custom CSS class on the widget, rather than fighting
 browser failures on various other selectors.
 

I had another look at the specs, and I agree that dots should be valid, but
it's pretty horrendous that neither Firefox nor Safari will let me style
that. If I've messed up the CSS syntax, let me know.


- -1 on changing the default behavior;  to paraphrase, broken browsers
you will have always with you.

+1 on changing 'renderTag' to use some kind of local policy (e.g.,
look up an 'ITagElementCleaner' utility) to spply such transforms.
E.g.::

def renderTag(tag, **kw):
cleaner = querytUtility(IWidgetTagCleaner)
if cleaner is None:
kw = cleaner(kw)
...


Yeah, this is nicer. I'd be happy to supply a patch for this. It would also
suport the case where you wanted to other standard transformations on
attributes.

I'd like to understand what the chances are of Plone 3 (whch will run on
Zope 2.10.x, whichever is latest when Plone is released in mid-May or a bit
later) being able to depend on this. We may need some kind of monkey patch
in Plone if it can't go into a real Zope release in time,

Martin
-- 
View this message in context: 
http://www.nabble.com/zope.app.form-generates-invalid-HTML-tf3276583.html#a9117875
Sent from the Zope3 - dev mailing list archive at Nabble.com.

___
Zope3-dev mailing list
Zope3-dev@zope.org
Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com



Re: [Zope3-dev] zope.app.form generates invalid HTML

2007-02-23 Thread Andreas Reuleaux
Try 
 
  #form\.title

i.e. you have to escape the dot otherwise
FF thinks it's for an element with class title

  ... id=form class=title ...


at least that works for me in a very simple example:

  p id=x.yhallo/p

  #x\.y {
...
  }

just my 2 cents

-Andreas


On Fri, Feb 23, 2007 at 02:13:23AM +, Martin Aspeli wrote:
 Hi guys,
 
 I'm pretty sure you're not allowed dots in ids of HTML elements. At 
 least not when they are prefixed by 'form'. A zope.schema.TextLine in a 
 formlib form, for example, generates HTML like this:
 
   input id=form.title class=textType type=text value=Changed 
 title size=20 name=form.title/
 
 In particular, we want to style the fields to look a bit more like 
 Plone, and we have special cases for title and description that we 
 want to style by ID, not class.
 
 However, CSS like this has no effect in Firefox or Safari:
 
 #form.title {
 font-size: 160%;
 font-family: dtml-var headingFontFamily;
 font-weight: normal;
 width: 99%;
 }
 #form.description {
 font: 100% dtml-var fontFamily;
 font-weight: bold;
 height: 6em;
 width: 99%;
 }
 
 Not all that surprising - it could look like I'm styling a form with 
 class=description.
 
 I then hacked zope.app.form.widget's renderElement() function to look 
 like this:
 
 def renderTag(tag, **kw):
 Render the tag. Well, not all of it, as we may want to / it.
 
  if 'id' in kw:
 kw['id'] = kw['id'].replace('.', '-')
 
  ...
 
 The tests in zope.app.form still pass.
 
 Hacky, but the alternatives are to (a) override all the widgets or (b) 
 at least provide custom ones only for the purpose of getting stylable 
 ids on various fields. renderTag() is called from a lot of places with 
 id=self.name. We could fix all those, too, of course.
 
 I would be happy to submit a patch for either the explicit check in 
 renderTag() or for changing all calls to this in zope.app.form.
 
 However, if someone has depended on the ids being with dots (possibly 
 not quite as likely as it may seem, since these forms are typically 
 auto-generated) then we may not have a decent way of deprecating that.
 
 Martin
 
 ___
 Zope3-dev mailing list
 Zope3-dev@zope.org
 Unsub: http://mail.zope.org/mailman/options/zope3-dev/reuleaux%40web.de
 
 
 
 !DSPAM:45defabb202742984811091!
___
Zope3-dev mailing list
Zope3-dev@zope.org
Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com