FWIW - My concern for this is primarily that as I add fields to tables months/years from now I may forget to set writable to False for them and therefore they would be set to NULL without my being aware. To get around this, I've added the following to my controllers that use SQLFORM.grid and call custom forms.
if request.args(0) == 'edit': for field in db.table_for_grid.fields: db.table_for_grid[field].writable = False db.table_for_grid.field_to_edit_1.writable = True db.table_for_grid.field_to_edit_2.writable = True ...etc... grid = SQLFORM.grid(db.table_for_grid.id > 0) -Jim On Monday, June 17, 2013 8:31:17 AM UTC-5, Jim S wrote: > > Not what I wanted to hear, but that is what I figured was the issue. > > However, I think it should be noted in the book that when using > SQLFORM.grid and custom forms that any field not included in the custom > form will be set to NULL on every update of the form. > > > > On Mon, Jun 17, 2013 at 12:53 AM, Massimo Di Pierro < > massimo.dipie...@gmail.com> wrote: > >> I am afraid this is not possible because HTML cannot distinguish an empty >> submission from no submission. Somehow we have to tell that explicitly to >> web2py. Perhaps there is a better way to do it but I do not see on. :-( >> >> >> On Sunday, 16 June 2013 15:35:27 UTC-5, Jim S wrote: >> >>> I thought I could just use whatever fields I wanted and it would figure >>> out which ones to update. The way it is now, if I add a field to a table >>> and it isn't included in the writable = False statements the It is going to >>> be set to null on any future updates. I would prefer to not have to worry >>> about updating all custom forms if I should add a field to a table sometime >>> in the future. >>> >>> Jim >>> On Jun 16, 2013 3:32 PM, "Massimo Di Pierro" <massimo....@gmail.com> >>> wrote: >>> >>>> How do you think it should work? If we can make it better we will. >>>> >>>> On Sunday, 16 June 2013 15:02:28 UTC-5, Jim S wrote: >>>>> >>>>> I was hoping I wouldn't have to do that but I understand. I think it >>>>> should be pointed out in the manual that this needs to be done so others >>>>> don't make the same mistake I did. >>>>> >>>>> Thanks Massimo, I really appreciate the reply. >>>>> >>>>> Jim >>>>> On Jun 16, 2013 3:41 AM, "Massimo Di Pierro" <massimo....@gmail.com> >>>>> wrote: >>>>> >>>>>> The problem is that the grid expects the field to be writable in the >>>>>> form. You do not include them therefore it thinks they are empty (html >>>>>> convention, not web2py's). >>>>>> >>>>>> Assuming you want the fields in the "create" form but not in the edit >>>>>> form you can replace: >>>>>> >>>>>> grid = SQLFORM.grid(db.person.id>0, >>>>>> fields=[db.person.first, db.person.last]) >>>>>> >>>>>> with >>>>>> >>>>>> if request.args(0) == 'edit': >>>>>> db.person.song.writable = False >>>>>> db.person.tv_show.writable = False >>>>>> grid = SQLFORM.grid(db.person.id>0, >>>>>> fields=[db.person.first, db.person.last]) >>>>>> >>>>>> On Friday, 14 June 2013 08:54:59 UTC-5, Jim S wrote: >>>>>>> >>>>>>> Here you go. Attached. >>>>>>> >>>>>>> -Jim >>>>>>> >>>>>>> >>>>>>> On Thursday, June 13, 2013 10:46:58 PM UTC-5, Massimo Di Pierro >>>>>>> wrote: >>>>>>>> >>>>>>>> Can we see an example? >>>>>>>> >>>>>>>> On Thursday, 13 June 2013 16:32:34 UTC-5, Jim S wrote: >>>>>>>>> >>>>>>>>> It is possible that I'm losing my mind, but it appears to me that >>>>>>>>> when I submit a SQLFORM.grid update with a custom form that fields >>>>>>>>> not >>>>>>>>> included in the custom form are being set to NULL even if they had a >>>>>>>>> value >>>>>>>>> in them before. >>>>>>>>> >>>>>>>>> I've just noticed this after updating to 2.5.1 stable. >>>>>>>>> >>>>>>>>> -Jim >>>>>>>>> >>>>>>>> -- >>>>>> >>>>>> --- >>>>>> You received this message because you are subscribed to a topic in >>>>>> the Google Groups "web2py-users" group. >>>>>> To unsubscribe from this topic, visit https://groups.google.com/d/** >>>>>> to**pic/web2py/EiAy_w4BLxY/**unsubsc**ribe<https://groups.google.com/d/topic/web2py/EiAy_w4BLxY/unsubscribe> >>>>>> . >>>>>> To unsubscribe from this group and all its topics, send an email to >>>>>> web2py+un...@**googlegroups.com. >>>>>> For more options, visit >>>>>> https://groups.google.com/**grou**ps/opt_out<https://groups.google.com/groups/opt_out> >>>>>> . >>>>>> >>>>>> >>>>>> >>>>> -- >>>> >>>> --- >>>> You received this message because you are subscribed to a topic in the >>>> Google Groups "web2py-users" group. >>>> To unsubscribe from this topic, visit https://groups.google.com/d/** >>>> topic/web2py/EiAy_w4BLxY/**unsubscribe<https://groups.google.com/d/topic/web2py/EiAy_w4BLxY/unsubscribe> >>>> . >>>> To unsubscribe from this group and all its topics, send an email to >>>> web2py+un...@**googlegroups.com. >>>> For more options, visit >>>> https://groups.google.com/**groups/opt_out<https://groups.google.com/groups/opt_out> >>>> . >>>> >>>> >>>> >>> -- >> >> --- >> You received this message because you are subscribed to a topic in the >> Google Groups "web2py-users" group. >> To unsubscribe from this topic, visit >> https://groups.google.com/d/topic/web2py/EiAy_w4BLxY/unsubscribe. >> To unsubscribe from this group and all its topics, send an email to >> web2py+unsubscr...@googlegroups.com. >> For more options, visit https://groups.google.com/groups/opt_out. >> >> >> > > -- --- 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/groups/opt_out.