Hi Matt, I've had similar problems with formatting the output of deform. When it comes to just changing the styles of the widgets of deform, the task is pretty easy. Take a look at http://docs.pylonsproject.org/projects/deform/dev/widget.html#widget-templates for information about overriding the default templates of the widgets.
As for changing oid, I've created a small patch that check to see whether a colander schema contains an oid attribute or not and then assigns that oid to the field directly. I don't know whether this is a good approach so I would love to hear from some of the main maintainers of deform. You can take a look at what I did here https://github.com/rob0t7/deform. I specifically created this because I was creating widgets that are disabled/enabled via javascript on the client side and I needed to be able to us oid more effectively. Hope some of this helps. RJ On 2011-06-22, at 2:03 PM, Matt Feifarek wrote: > Hi. I'm working with deform. I'm resisting the urge to make my own templates, > as my needs are not all that custom; I simply want to do simple things like > having radio choices side-by-side rather than stacked up, or having some > fields on the left column, some in the right. So, I'm looking at the > generated html and hoping to use css selectors to style my deform output. > For the radio button task just redefine the radio widget template. > I'm having trouble finding out how to set class and id attributes, and I see > things like this in the code: > > field.py: > self.oid = 'deformField%s' % self.order > > hidden.pt: > <input type="hidden" name="${field.name}" value="${cstruct}" > id="${field.oid}"/> > > This would seem to indicate that users of deform have no way to set the dom > id of a form element. Is this true? Having them enumerated as such means we > could look into the generated code and then make a style sheet, but this > would be super-brittle, especially if the forms were generated and the order > wasn't necessarily super predictable. > > I do see that we can pass "css_class" to widgets, but this doesn't affect the > <li> or <label> or anything; it's not much use to only style the input > element. > > Also, it doesn't seem like the templates actually lead to the expected > output... for example, here is textinput.pt: > <span tal:omit-tag=""> > <input type="text" name="${field.name}" value="${cstruct}" > tal:attributes="size field.widget.size; > class field.widget.css_class" > id="${field.oid}"/> > <script tal:condition="field.widget.mask" type="text/javascript"> > deform.addCallback( > '${field.oid}', > function (oid) { > $("#" + oid).mask("${field.widget.mask}", > > {placeholder:"${field.widget.mask_placeholder}"}); > }); > </script> > </span> > > And here is a textinput as rendered by form.render(): > <li title="" id="item-deformField1"> > <!-- mapping_item --> > <label class="desc" title="" for="deformField1">Email<span class="req" > id="req-deformField1">*</span> > </label> > <input type="text" name="email" value="hi" id="deformField1" /> > <!-- /mapping_item --> > </li> > > What happened to the span? Where did the <label> come from? This may just be > me not understanding Chameleon templates... > > What are some good strategies for working with styling deform output? Maybe > someone can point me to a post somewhere, or maybe just help? > > Thanks. > > > -- > You received this message because you are subscribed to the Google Groups > "pylons-discuss" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/pylons-discuss?hl=en. -- You received this message because you are subscribed to the Google Groups "pylons-discuss" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
