Check -- that did the trick.

I didn't know that specifying the fields in the SQLFORM had this
effect on the scope of the update. You live and learn...

Thanks for the support!
-Peter

On Dec 28, 7:48 pm, mdipierro <mdipie...@cs.depaul.edu> wrote:
> I see. You need
>
>     form=SQLFORM(db.t2_person,vrouw,fields=[....])
>
> instead of
>
>     form=SQLFORM(db.t2_person,vrouw)
>
> else you have errors in fields that are not visualized by the custom
> form. You can check this by printing:
>
>     {{=form.errors}}
>
> Massimo
>
> On Dec 28, 12:02 pm, Peter <peter.kleyn...@gmail.com> wrote:
>
> > Oh -- forgot to say: the same SQLFORM for a t2_person embedded in the
> > view with {{=form}} DOES work.
> > So it seems there's a relationship between the t2 stuff and this
> > specific way to build a custom form?
>
> > Just to reiterate, the problem is still this: >> nothing happens if I
> > click submit (no flash message, no
> > update in db). <<
>
> > Cheers,
> > -Peter
>
> > On Dec 28, 6:50 pm, Peter <peter.kleyn...@gmail.com> wrote:
>
> > > Massimo, thanks for the incredibly fast turnaround -- on a Sunday
> > > even. ;-)
>
> > > I've done some more experimenting. This works beautifully on my
> > > PRODUCT table. I do have to add the name="id" to the form, as you
> > > suggested, to prevent a "user is tampering with form" error.
>
> > > BUT I keep having the same problem as described above with my
> > > T2_PERSON extended table. Adding the name="id" field makes no
> > > difference.
>
> > > If you have any further ideas, please let me know... Somehow related
> > > to T2??
> > > Cheers,
> > > -Peter
>
> > > In db.py:
> > > db.define_table('t2_person',
> > >     SQLField('name',length=40,requires=IS_NOT_EMPTY()),
> > >     SQLField('password','password',requires=CRYPT()),
> > >     SQLField('email',requires=IS_EMAIL()),
> > >     SQLField('registration_key',length=64),
> > >     SQLField('voornaam'),
> > >     SQLField('achternaam',length=50),
> > >     SQLField('adres',length=100),
> > >     SQLField('plaats',length=50),
> > >     SQLField('postcode',length=10),
> > >     SQLField('landcode',db.land),
> > >     SQLField('telnr',length=15),
> > >     SQLField('foto','upload'),
> > >     SQLField('created_by_ip'),
> > >     SQLField('created_on','datetime'))
>
> > > db.t2_person.name.requires=IS_NOT_EMPTY()
> > > db.t2_person.landcode.requires=IS_IN_DB(db,'land.id','%(landnaam)s')
> > > db.t2_person.email.requires=[IS_EMAIL(),IS_NOT_IN_DB
> > > (db,'t2_person.email')]
> > > db.t2_person.password.requires=[IS_NOT_EMPTY(),CRYPT()]
> > > db.t2_person.exposes=
> > > ['name','email','password','voornaam','achternaam','adres','plaats','postcode','landcode','telnr','foto']
> > > db.t2_person.displays=
> > > ['name','email','voornaam','achternaam','adres','plaats','postcode','landcode','telnr','foto']
> > > ...
> > > ...
> > > from applications.mijnmoem.modules.t2 import T2
> > > t2=T2(request,response,session,cache,T,db)
>
> > > On Dec 28, 5:33 pm, mdipierro <mdipie...@cs.depaul.edu> wrote:
>
> > > > try add
>
> > > > <input name="id" value="{{=form.record.id}}" type="hidden" />
>
> > > > On Dec 28, 9:22 am, Peter <peter.kleyn...@gmail.com> wrote:
>
> > > > > Massimo, I'm trying to use this technique, as follows:
>
> > > > > Controller:
> > > > > def inschrijving():
> > > > >     vrouw=db(db.t2_person.id==t2.person_id).select()[0]
> > > > >     form=SQLFORM(db.t2_person,vrouw)
> > > > >     if form.accepts(request.vars,session):
> > > > >         response.flash='OK.'
> > > > >     return dict(form=form)
>
> > > > > View (inschrijving.html):
> > > > > {{extend 'layout.html'}}
> > > > > <form>
> > > > > <label>{{=db.t2_person.name.label}}</label>
> > > > > <input name="name" value="{{=form.latest.name}}" />
> > > > > <label>{{=db.t2_person.landcode.label}}</label>
> > > > > <input name="landcode" value="{{=form.latest.landcode}}" />
> > > > > {{if form.errors.landcode:}}{{=form.errors.landcode}}{{pass}}
> > > > > <input type="submit" value="Save"/>
> > > > > {{=form.hidden_fields()}}
> > > > > </form>
>
> > > > > I can't get much closer to the snippet that you posted than this? ;-)
>
> > > > > Problem: nothing happens if I click submit (no flash message, no
> > > > > update in db).
> > > > > Among much else, I've tried:
> > > > > - adding "action" and "method' attributes to form;
> > > > > - form.accept with "formname=None" instead of session;
> > > > > - form.accept without any second argument
> > > > > -- no luck with any of them.
>
> > > > > What am I doing wrong??
>
> > > > > Cheers,
> > > > > -Peter
>
> > > > > On Nov 10, 9:15 pm, mdipierro <mdipie...@cs.depaul.edu> wrote:
>
> > > > > > You can havecustomforms. You always could. Since version 1.48
> > > > > > (posted today) it is even easier:
>
> > > > > > #in model:
>
> > > > > > db.define_table('mytable',SQLField('myfield'))
>
> > > > > > #in controller:
>
> > > > > > def index():
> > > > > >     form=SQLFORM(db.mytable)
> > > > > >     if form.accepts(request.vars,session):
> > > > > >          response.flash='form accepted'
> > > > > >     return dict(form=form)
>
> > > > > > #and in view:
>
> > > > > > {{extend 'layout.html'}}
>
> > > > > > <form>
> > > > > > <label>{{=db.mytable.myfield.label}}</label>
> > > > > > <input name="myfield" value="{{=form.latest.myfield}}" />
> > > > > > {{if form.errors.myfield:}}{{=form.errors.myfield}}{{pass}}
> > > > > > <input type="submit" />
> > > > > > {{=form.hidden_fields()}}
> > > > > > </form>
>
> > > > > > Massimo
>
> > > > > > On Nov 10, 2:04 pm, "Daniel Guryca" <dun...@gmail.com> wrote:
>
> > > > > > > Hey totally agree with you !
>
> > > > > > > It is too bad not to be able to define my own fully 
> > > > > > > customizedforms
> > > > > > > within a view,
> > > > > > > operate over them in a controller but still need to have a 
> > > > > > > necessary
> > > > > > > relation to a database model !
>
> > > > > > > Logic should be defined in a controller and presentation in a 
> > > > > > > view.
>
> > > > > > > Daniel
>
> > > > > > > On Mon, Nov 10, 2008 at 2:23 PM, billf 
> > > > > > > <billferr...@blueyonder.co.uk> wrote:
>
> > > > > > > > Hi All
>
> > > > > > > > I know that there is a patch related tocustomviews in the 
> > > > > > > > pipeline
> > > > > > > > but this proposal is another step on from that.
>
> > > > > > > > I am proposing an additional approach that enables those things 
> > > > > > > > that
> > > > > > > > (I consider) are view-related to be moved from the model and
> > > > > > > > controller to the view.  In addition, it provides separation of 
> > > > > > > > html
> > > > > > > > form from model related logic such as validation and db 
> > > > > > > > updating.
>
> > > > > > > > There are still some areas to be covered but I have written a 
> > > > > > > > page
> > > > > > > > that, hopefully, explains the ideas at
>
> > > > > > > >http://www.wellbehavedsystems.co.uk/web2py/examples/mvc.html
>
> > > > > > > > All comments gratefully accepted.
--~--~---------~--~----~------------~-------~--~----~
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