On Mar 21, 12:02 pm, "Ian Wilson" <[EMAIL PROTECTED]> wrote:
> This thread has been raging for a while and it is confusing me.
>
> Are you talking about this kind of functionality?
>
> In controller:
> form = w.TableForm(fields = [w.TextField('userName')])
>
> In template:
> ${form(attrs=dict(userName=dict(maxlength='12')))}
>
> The attribute readonly might work but i'm not really familiar with
> valueless attributes(selected, checked, readonly).  I think readonly
> is kind of new to non-ms browsers as well.  I really never understand
> why you would use it either.
>

Not really.

More like:

Declare the form statically as per now.

class MyFields(widgets.WidgetsList):
    description = widgets.TextField(label="Description")

class MyForm():
    fields = MyFields()

in the page handler:

     form = MyForm()
     if user.is_restricted:
        form['description'].update_attrs({'readonly':'readonly'})
        form['description'].label = "A different label"
.....

I.e. I would like to "create" a form instance, modify a few bits
(perhaps) then send it to the template for display together with the
values as per now.

Most, if not all of this should really be done in the controller
without putting to much extra logic in the template. This way, you
still only need ${form.display(value=myvalues)} in the template....

With the current widgets implementation this is not possible except by
creating custom widgets/subclassing.

Needs some thinking about......

BTW, using xhtml you should not have valueless attributes. you should
say something like readonly="readonly", checked="checked" or some
such.

Regards,
Gary.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears" 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/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to