[Twisted-web] How to set the selected item in a select box?

Thomas HERVE therve at free.fr
Wed Jul 20 10:26:04 MDT 2005

Quoting Alberto Trujillo <alberto.trujillo at ucd.ie>:

> The problem is that the attribute selected allways appear in my html 
> code, and then allways the last item is the selected.
> Can anybody tell me how to fix this problem? If possible don't use a 
> attribute even when I have set this one in my template?

selected is a strange attribute as it don't have a value. You can use this :

    def render_selectauthor(self, ctx, data):
        author = data.firstname + " " + data.lastname
        ctx.fillSlots("authorvalue", data.id)
        ctx.fillSlots("authorlabel", author)
        if data.id == self.idauthor:
            return ctx.tag(selected=True)
            return ctx.tag

and remove the slot "selected" in your template.


More information about the Twisted-web mailing list