Stephan,

I think I am not completely understanding what you need. can you make
a concrete example of a model, how the model should look like (use a
drawing or text) and what should happen when the form is submitted?

Massimo

On Oct 26, 1:33 pm, znafets <[email protected]> wrote:
> @weheh: I saw that but couldn't take too much from it
> @Thadeus: Woooa, that looks like for a second generation BF compiler -
> I am blinded :) , thank you anyway
> @Massimo: I knew you would like that highly sophisticated stuff but
> please don't ask me if it helps to solve my problem, or better put: is
> this the only solution to that use case I described ? Then I guess
> this is way out of my league and incomprehensible for my old eyes.
>
> I adored web2py so far for being easy to use and elegant, but in this
> specific case I am willing to rethink that impression in a way that it
> may be easy as long as one stays on well flattened roads leading to
> standard views with minimum customization. Once you are passed that it
> seems to get really hairy.
>
> to recap:
> getting data from two tables displayed in a view with fields that are
> supposed to appear where I want them, pre-filled with the data that is
> already in the db is this the only way to do it in web2py ?
> seriously ? No easier, better, smoother way ?
>
> ciao
> Stefan
>
> On 26 Okt., 18:00, mdipierro <[email protected]> wrote:
>
> > An aesthetic issue. Consider you can replace:
>
> > {{
> > def req():
> >     return XML('''<span class="required">*</span>''')
>
> > }}
>
> > with
>
> > {{req=SPAN("*",_class="required")}}
>
> > and call it with {{=req}} or
>
> > {{def req():}}<span class="required">*</span>{{return}}
>
> > and call it with {{req()}} (no equal)
>
> > Massimo
>
> > On Oct 26, 11:51 am, Thadeus Burgess <[email protected]> wrote:
>
> > > This is usually what I end up doing for custom form. It allows for fully
> > > customizable XHTML/CSS 3 forms.
>
> > > {{
> > > def req():
> > >     return XML('''<span class="required">*</span>''')}}
>
> > > {{pass}}
>
> > > {{def labels(field, required):}}
> > >                 <label for="{{=field}}" id="{{=field}}__label"
> > > class="title">{{=form.custom.label[field]}}{{if
> > > required:}}{{=req()}}{{pass}}</label>
> > >                 <label for="{{=field}}" id="{{=field}}__comment"
> > > class="comment">{{=form.custom.comment[field]}}</label>
> > >                 <label for="{{=field}}" id="{{=field}}__error"
> > > class="error">{{if
> > > form.errors.has_key(field):}}{{=form.errors[field]}}{{pass}}</label>
> > > {{pass}}
>
> > > {{def li(field, required=True):}}
> > >         <li {{if form.errors.has_key(field):}}class="err"{{pass}}>
> > >             <div class="labels">
> > >                 {{labels(field, required)}}
> > >             </div>
> > >             {{=form.custom.widget[field]}}
> > >         </li>
> > > {{pass}}
>
> > > {{=form.custom.begin}}
>
> > > <fieldset>
> > >     <legend></legend>
> > >     <ol>
> > >         {{li('signup_code')}}
> > >     </ol>
> > > </fieldset>
>
> > > <fieldset>
> > >     <ol>
> > >         <li>
> > >             <div class="labels">
> > >                 <label for="submit" class="title">Click to finish and 
> > > submit
> > > your information.</label>
> > >             </div>
> > >             <input type="submit" class="submit" value="Submit" />
> > >         </li>
> > >     </ol>
> > > </fieldset>
>
> > > {{=form.custom.end}}
>
> > > -Thadeus
>
> > > On Mon, Oct 26, 2009 at 7:43 AM, weheh <[email protected]> wrote:
>
> > > >http://groups.google.com/group/web2py/browse_thread/thread/c6e3021507...
>
> > > > On Oct 26, 7:55 am, znafets <[email protected]> wrote:
> > > > > the call to form.accepts fails with "key error" no-table ... after the
> > > > > form gets submitted...
>
> > > > >   if form.accepts(request.vars, session):
>
> > > > > On 26 Okt., 11:05, znafets <[email protected]> wrote:
>
> > > > > > Hi Thadeus, weheh,
>
> > > > > > if I make it read like this:
>
> > > > > >         req_user_id = request.args[0]
>
> > > > > >         user = db((db.user.id == req_user_id) &
> > > > > >                             (db.addr.user == 
> > > > > > req_user_id)).select()[0]
>
> > > > > >         db.user.id.default = user.user.id
> > > > > >         db.user.name.default = user.user.name
> > > > > >         db.user.email.default = user.user.email
> > > > > >         db.addr.city.default = user.addr.city
>
> > > > > >         form = SQLFORM.factory(db.user.name, db.user.rname,
> > > > > > db.addr.city)
>
> > > > > > pre populating works.
>
> > > > > > @weheh: can you post an example how you take it from there with the
> > > > > > custom.form technics ?
>
> > > > > > thanls
> > > > > > Stefan
>
> > > > > > On 26 Okt., 07:06, weheh <[email protected]> wrote:
>
> > > > > > > This is an unsolicited testimonial. I've been doing this kind of
> > > > > > > multi-
> > > > > > > table-form thing now for about a month or two. I collect data for
> > > > > > > specific fields for multiple tables (2 or 3 at a time) using
> > > > > > > SQLFORM.factory forms and use form.custom.begin ... 
> > > > > > > form.custom.end
> > > > > > > in
> > > > > > > my views. At first, it felt all cold, slobbery and gross. Utterly
> > > > > > > unintuitive. A total WET (Widespread Echoed Text) LICK (Long
> > > > > > > Incredibly
> > > > > > > Chaotic Kode). But now that I've sort'a mastered it and refactored
> > > > > > > everything, it feels kind'a like a warm DRY KISS. I agree with
> > > > > > > Thadeus, it ain't pretty, at least not as pretty as straight 
> > > > > > > SQLFORM
> > > > > > > or FORM or CRUD. But it works. And it gives you complete 
> > > > > > > flexibility
> > > > > > > in terms of form structure and layout while maintaining a separate
> > > > > > > database structure that's designed for efficiency rather than easy
> > > > > > > form layout. Is there a better way? I dunno ... my mind can't lift
> > > > > > > heavy loads like that any more. Anyway, that's as far as my 2 
> > > > > > > cents
> > > > > > > goes. Cheers.
>
> > > > > > > On Oct 25, 2:11 pm, Thadeus Burgess <[email protected]> wrote:
>
> > > > > > > > Ah yes, forgot to add the field to the end of it. Thats what
> > > > happens when I
> > > > > > > > write code in email :)
>
> > > > > > > > SQLFORM.factory(db.user.name, db.address.street)
>
> > > > > > > > -Thadeus
>
> > > > > > > > On Sun, Oct 25, 2009 at 12:38 PM, mdipierro <
> > > > [email protected]> wrote:
>
> > > > > > > > > This
>
> > > > > > > > > > SQLFORM.factory(
> > > > > > > > > > db.user, db.address
> > > > > > > > > > )
>
> > > > > > > > > will not quire work because both tables contain an Id field. I
> > > > think
> > > > > > > > > you need to explicitly list the fields to you want.
>
> > > > > > > > > Massimo
>
> > > > > > > > > On Oct 25, 11:50 am, Thadeus Burgess <[email protected]>
> > > > wrote:
> > > > > > > > > > znafets, Keeping the thread in this post...
>
> > > > > > > > > > user = db((db.user.id == request.id) & (db.address.id_user 
> > > > > > > > > > ==
> > > > request.id
> > > > > > > > > > )).select()
>
> > > > > > > > > > db.user.id.default = user.id
> > > > > > > > > > db.user.name.default = user.name
> > > > > > > > > > db.user.email.default = user.email
>
> > > > > > > > > > SQLFORM.factory(
> > > > > > > > > > db.user, db.address
> > > > > > > > > > )
>
> > > > > > > > > > Is there another way of doing this? To me, this is not DRY 
> > > > > > > > > > or
> > > > KISS.
>
> > > > > > > > > > -Thadeus
>
> > > > > > > > > > On Sat, Oct 24, 2009 at 3:20 PM, Renato-ES-Brazil
> > > > > > > > > > <[email protected]>wrote:
>
> > > > > > > > > > > Massimo,
>
> > > > > > > > > > > Sorry, your message to Thadeus, which also answered my
> > > > question,
> > > > > > > > > > > appeared only after, when I sent my question to this 
> > > > > > > > > > > topic.
>
> > > > > > > > > > > My example had just one table because it was a simple test
> > > > with
> > > > > > > > > > > SQLFORM.factory.
>
> > > > > > > > > > > I thought it worked this way that you mentioned, but when 
> > > > > > > > > > > I
> > > > saw that
> > > > > > > > > > > the SQLFORM.factory allows to send some parameters like
> > > > > > > > > > > "db.table.field" instead of using Field(), I got confused.
> > > > :-)
>
> > > > > > > > > > > On 24 out, 18:07, mdipierro <[email protected]> 
> > > > > > > > > > > wrote:
> > > > > > > > > > > > A SQLFORM.factory has no knowledge of the underlying
> > > > database. If you
> > > > > > > > > > > > use SQLFORM.factory you should do the inserts/update
> > > > manually.
>
> > > > > > > > > > > > In your case your form involves a single table so you
> > > > should just use
> > > > > > > > > > > > crud.create or crud.update
> > > > > > > > > > > > use db.table.field.writable and db.table.field.readable 
> > > > > > > > > > > > and
> > > > > > > > > > > > db.table.field.default to change the behavior of the 
> > > > > > > > > > > > form.
>
> > > > > > > > > > > > On Oct 24, 3:02 pm, Renato-ES-Brazil <
> > > > [email protected]>
> > > > > > > > > wrote:
>
> > > > > > > > > > > > > Massimo,
>
> > > > > > > > > > > > > I tried to use SQLFORM.factory just for tests:
>
> > > > > > > > > > > > > def edit():
> > > > > > > > > > > > >     task_id = request.args(0)
> > > > > > > > > > > > >     task=db(db.task.id==task_id).select()[0]
> > > > > > > > > > > > >     form=SQLFORM.factory(db.task.title,
> > > > db.task.description,
> > > > > > > > > > > > > record=task)
> > > > > > > > > > > > >     if form.accepts(request.vars, session):
> > > > > > > > > > > > >         response.flash = 'form accepted'
> > > > > > > > > > > > >     elif form.errors:
> > > > > > > > > > > > >         response.flash = 'form has errors'
> > > > > > > > > > > > >     else:
> > > > > > > > > > > > >         response.flash = ''
> > > > > > > > > > > > >     return dict(form=form)
>
> > > > > > > > > > > > > The message "form accepted" was shown but the record 
> > > > > > > > > > > > > was
> > > > not
> > > > > > > > > updated.
> > > > > > > > > > > > > What should I do for work?
>
> > > > > > > > > > > > > On 24 out, 17:32, Thadeus Burgess 
> > > > > > > > > > > > > <[email protected]>
> > > > wrote:
>
> > > > > > > > > > > > > > >>>form=SQLFORM.factory(db.
>
> > > > > > > > > > > > > > > table1.field1,db.table2.field2)
>
> > > > > > > > > > > > > > Does this allow for the data to be inserted into the
> > > > database? I
>
> ...
>
> read more »
--~--~---------~--~----~------------~-------~--~----~
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