Maybe this line:

value="{{=profileSet.latest.firstname}}"/>

should be

value="{{=profileSet.formsetting.latest.firstname}}"/>

On May 25, 11:51 pm, mdipierro <mdipie...@cs.depaul.edu> wrote:
> please email me your code although I cannot promise I will have time
> within the next 2 days.
>
> Massimo
>
> On May 25, 9:10 pm, Yannick <ytchatch...@gmail.com> wrote:
>
>
>
> > Hello Massimo,
> > Thanks for your note but unfortunately I still have the same error
> > message even after making the change you proposed....
> > Here is the change i made:
>
> > 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),
> >                                         SQLField
> > ('address1',label='Address 1',requires=IS_NOT_EMPTY(),
> > default=default_address1))
>
> >  if settingform.accepts(request.vars, session, keepvalues=True,
> > formname='setting'):
>
> > I still have the error saying:
> >  <AttributeError: 'str' object has no attribute 'latest' >
>
> > Please note that the fields inside the 'settingform' define earlier
> > are coming from different tables... Like Fields "address1" are coming
> > from "Address" Table and fields "Firstname and Lastname" from table
> > "Person"... Do you think it may be the cause of my problem ????
>
> > Thanks a lot,
> > Yannick P
>
> > On May 24, 10:53 pm, mdipierro <mdipie...@cs.depaul.edu> wrote:
>
> > > 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 <ytchatch...@gmail.com> 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 web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to