add record no longer available in smartgrid since switch to ms sql

29 views
Skip to first unread message

Davidiam

unread,
Jan 18, 2024, 7:47:37 AMJan 18
to web2py-users
I recently switched from sqlite to MS SQL and my application no longer allows me to add new records using the smartgrad.  I have editable and deletable set to True but I can only view the records.

If I use a basic SQLFORM I can add records, but I would prefer using the smartgrid.
Is there a trick to getting it working with MS SQL?

This only allows me to view the record:
    grid = SQLFORM.smartgrid(db.image, create=True, editable=True, deletable=True, linked_tables=['post'])
    return dict(grid=grid)

With this is I can add new records:
    record = db.image(request.args(0))  # Tries to get  an existing record where the id is specified in the first argument if the url.
   
    image_form = SQLFORM(db.image, record)  # Creates a form based on the 'image' table. If a record was found, it will show the record details
   
    if image_form.process().accepted:  # When the form is submitted (not when it is created) it will try and process it and add the record or save any changes to the record.
        response.flash = 'form accepted'
    elif image_form.errors:
        response.flash = 'form has errors'
    return dict(grid=image_form)

Kind Regards,
David

Davidiam

unread,
Jan 18, 2024, 7:52:56 AMJan 18
to web2py-users
I found the reason.  I needed to add  user_signature=False

The default for this parameter is True and will prevent you from adding records!!!
Reply all
Reply to author
Forward
0 new messages