[Twisted-web] Grouping controls in formless layouts

Phil Mayers p.mayers at imperial.ac.uk
Wed May 25 08:54:40 MDT 2005


All,

I have a table-based layout (yes I know) which uses the slots/patterns 
and an XML template to lay the form out:

<form xmlns:n="http://nevow.com/ns/nevow/0.1" n:pattern="freeform-form">
  <!-- blah, lots of stuff here -->
  <table>
    <n:invisible n:pattern="argument" n:render="remove">
      <tr><td><n:slot-name="input"/></td></tr>
    </n>
  </table>
</form>

...however I want to group some of the controls together in the table. 
The problem is that this:

<form xmlns:n="http://nevow.com/ns/nevow/0.1" n:pattern="freeform-form">
  <!-- blah, lots of stuff here -->
  <table>
    <n:invisible n:pattern="argument" n:render="remove">
      <tr>
        <td><n:slot-name="description"/></td>
        <td><n:slot-name="input"/></td>
      </tr>
    </n>

    <tr>
      <td>Age</td>
      <n:invisible n:pattern="argument!!age" n:render="remove">
        <td><n:slot-name="input"/></td>
      </n>
      <n:invisible n:pattern="argument!!ageunits" n:render="remove">
        <td><n:slot-name="input"/></td>
      </n>
  </table>
</form>

...generates this:

<table>
   <tr>
     <td>field 1</td>
     <td><input type="text" name="field1"/></td>
   </tr>

   <td><input type="text" name="age"/></td>
   <td><select name="age"><!--blah--></select></td>

   <tr>
     <td>Age</td>
   </tr>
</table>

...that is, the patterns are yanked out of their inner context (as you 
would expect I guess).

The labours of why this needs to be table-based need not be raised here 
- suffice it to say I'm not the one making the decision. Having said 
that I can see the argument that making a proper resizing gridbag-style 
layout with CSS is basically impossible (and that infuriates me).

I suspect I can subclass annotate.Typed or use the complexType stuff to 
somehow group a textbox and dropdown together into one logical bit of 
HTML that is rendered as a single "control".

Does anyone have any examples of how I might do that or similar to 
aggregate various form control?



More information about the Twisted-web mailing list