I believe the problem is that profileSet.latest is created bu
SQLFORM.accepts and not FORM.accepts. Consider replacing this
settingform = FORM('First Name:', INPUT(_name='firstname',
requires=IS_NOT_EMPTY(), value= "%s"%default_firstname),
'Last Name:', INPUT(_name='lastname',
requires=IS_NOT_EMPTY(), value= "%s"%default_lastname),
INPUT(_type='submit') )
.....
if FORM.accepts(settingform, request.vars, session, keepvalues=True):
# Some code here#
with
from gluon.sqlhtml import form_factory
settingform = form_factory(SQLField('firstname',label='First Name',
requires=IS_NOT_EMPTY(),default=default_firstname),
SQLField('lastname',label='Last Name',
requires=IS_NOT_EMPTY(), default=default_lastname))
if form.accepts(request.vars, session, keepvalues=True,
formname='settingform'):
On May 24, 9:34 pm, Yannick <[email protected]> wrote:
> Hello Mate,
>
> I have a page called "index.html" with several form inside... here is
> a sample of my code:
> ##################
> #Controller:
> ##################
>
> @auth.requires_login()
> def pwdSetting(): return dict(chg_pwd = auth.change_password())
>
> @auth.requires_login()
> def profileSetting():
> # Some code here where I defined: default_firstname and
> default_lastname
> settingform = FORM('First Name:', INPUT(_name='firstname',
> requires=IS_NOT_EMPTY(), value= "%s"%default_firstname),
> 'Last Name:', INPUT(_name='lastname',
> requires=IS_NOT_EMPTY(), value= "%s"%default_lastname),
> INPUT(_type='submit') )
> .....
> if FORM.accepts(settingform, request.vars, session, keepvalues=True):
> # Some code here#
> .....
> return dict(formsetting=settingform)
>
> @auth.requires_login()
> def index():
> profileSet = profileSetting()
> pwdSetting = pwdSetting()
> return dict( profileSet=profileSet, pwdSet=pwdSetting)
>
> ###########
> # index.html
> ###########
> Profile Setting:
> <form action="" enctype="multipart/form-data" method="post">
> First Name:
> <input name="firstname" type="text"
> value="{{=profileSet.latest.firstname}}"/>
> Last Name:
> <input name="lastname" type="text"
> value="{{=profileSet.latest.lastname}}"/>
> <input type="submit" value="Submit" />
> ....
> ....
> {{=profileSet.hidden_fields()}}
> </form>
>
> Password Setting:
> <h1> Password Setting </h1>
>
> <form action="" enctype="multipart/form-data" method="post">
> Old Password:
> <input name="old_password" type="password" value="" />
> New Password:
> <input name="new_password" type="password" value="" />
> Re-Type Password:
> <input name="new_password2" type="password" value="" />
> <input type="submit" value="Submit" />
> {{=pwdSet.hidden_fields()}}
> </form>
>
> ############################################################
>
> When I do this i have an error message saying :
> "AttributeError: 'str' object has no attribute
> 'latest'"
>
> Does any one has an idea how to solve this problem... The way i design
> it i want to have each controller for each form... I can make this
> work by have a BIG controller 'Index' that define and return several
> form BUT this solution is difficult to maintain and may trigger a bad
> performance....
>
> Please let me know if you have any idea... Thank You.
>
> Yannick P.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"web2py Web Framework" 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
-~----------~----~----~----~------~----~------~--~---