Hi.

I'm still searching to make a really simple form with these tables, one to 
many relation.

Here is my db:
#ONE
    db.define_table('categories',
        Field('description_en', requires=IS_NOT_EMPTY()),
        Field('description_it', requires=IS_NOT_EMPTY()),
        Field('code', requires=IS_NOT_EMPTY()))
#MANY
    db.define_table('models',
        Field('code', unique=True, requires=IS_NOT_EMPTY()),
        Field('category_id', 'integer', 'reference categories', 
requires=IS_NOT_EMPTY()),
        Field('description_en', requires=IS_NOT_EMPTY()),
        Field('description_it', requires=IS_NOT_EMPTY()),
        Field('pdf_path', requires=IS_NOT_EMPTY()))

Now when I add rows to my "models" table in db administration I set the 
"category_id" field by number.

I just would like to make a form for "models" table where I will be able to 
set the "models.category_id" field choosing by the 
"categories.description_it" field.

How can I do it with the SQLFORM API ? I've made this in my controller:
def edit_models():
    query = db.models.category_id==db.categories.id
    fields = 
(db.models.code,db.categories.description_it,db.models.description_it,db.models.pdf_path)
    grid = SQLFORM.grid(query, fields=fields, editable=True, 
deletable=True, create=True)
    return dict(grid=grid)

I've set "editable=True, deletable=True, create=True" and I cannot do any 
of these three actions. And in any case I can imagine that if I edit 
db.categories.description_it I'm gone change this field inside the 
categories table instead of setting the category_id field in the models 
table.

Perhaps I have to do it with the FORM API ?

Thanks in advance.

-- 
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 [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to