Hello.

This is just a simple example, my actual model is more complex, but I think 
I can explain the main idea.

Model:

db.define_table('users',
                Field('name', 'string'))

db.define_table('contacts',
                Field('user', db.users),
                Field('phone', 'string'))
                

Well, each user can have from 1 to infinite phone numbers.
I want user entering all his numbers while registering.

So, what are the ways to realize it?

1) Split registration process to steps, step one - enter name, step two - 
add phones one by one. Ugly.
2) Use smartgrid. Have "parent-children" out of the box. Being, may be, 
cool tool for admin purposes, it is absolutely unintuitive and unusable for 
end-users.
3) Make custom form with jquery: form have button "add another phone 
number", user press the button and another text field adding dynamicaly for 
the "infinite" form. Excellent way. But. This is theoretically. And I cant 
find any practical examples.

So, testing I can see that inputs with same name processing by web2py as a 
list, its fine! For example, there is a duplicated inputs in the form:

<input name="phone" type="text">
<input name="phone" type="text">

after submitting, I have ['123456','345678'] on form.vars.phone. Cool. 
Cycle and do "db.insert()" voila, you say!

No.

Linked table "contacts" actually is more more complex. It have "address" 
string, "state" string, "postal", validators and another linked tables such 
"postals", "cities", etc, etc...

And I have no idea how build my form and how to process my form vars within 
controller with all "contact" table validators?
Is there any elegant way doing this?

Found this:
http://www.web2pyslices.com/slice/show/1427/single-form-for-linked-tables
not so helpful.

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to