On Sep 6, 2009, at 9:03 AM, weheh wrote:

> After further consideration, I think that, although the "trick":
>  db.table1.field1.readable=db.table1.field1.writable=False
> does work by adding it to the controller so that it only applies to
> the current form, in practice this isn't practical in my case. For
> instance, I need to use the fields in the form to write a value to
> field1, which I think the above statement would make impossible. Also,
> if the table1 has many fields and the form only populates one of the
> fields, then this approach makes for some pretty ugly controller code.
>
> Given the high degree of control I need over the form, I think the
> right way to do this is to use the SQLFORM.factory in the controller
> and custom form code within the view. Something like this:
>
> # Controller:
> form = SQLFORM.factory(
>  Field('text','string',requires=IS_NOT_NULL()),
>  db.table1,
>  db.table2,
>  )
>
> # View:
> {{=form.custom.begin}}
> {{=TABLE(TR(TH(T('Enter field 1')),TD(form.custom.widget.text)),
>         TR(TH(form.custom.labels['xyz']),TD
> (form.custom.widget.table1.xyz)))}}
> {{=form.custom.submit}}
> {{=form.custom.end}}
>
> I'm trying to get this to work, but the form.custom.labels['xyz']
> keeps on throwing an error:
>  AttributeError: 'NoneType' object has no attribute 'xyz'
>
> where table1 is defined with Field('xyz','string',label=T('Option
> List:'),requires=IS_IN_SET(['a','b','c']))
>
> Anybody have any idea why this isn't working?

form.custom.labels -> form.custom.label?

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

Reply via email to