Re: How to handle a submitted form with no changes -- best practices sought

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, 2010-09-12 at 16:12 -0500, Tamara Temple wrote:

> On Sep 12, 2010, at 3:34 PM, Robert Cummings wrote:
> 
> > On 10-09-11 12:52 PM, Tamara Temple wrote:
> >> I have a general question and am looking for best practices.
> >>
> >> Suppose I present a user with a form for editing an entry in a table,
> >> i.e., the form has filled in values from the existing table entry.
> >>
> >> Now, suppose they click on 'submit' without making any changes in the
> >> form. (Perhaps, say, rather than clicking 'Cancel' or 'Return to  
> >> Main'
> >> or some other option which would get them out of that screen without
> >> submitting the form).
> >>
> >> Is it worth the overhead of passing along the previous values in the
> >> table in hidden fields so that fields can be checked to see if  
> >> they've
> >> been updated or not after the submit? Or is it worth reloading the  
> >> old
> >> values from the table to check against the newly submitted form? Or  
> >> is
> >> all that overhead not worth the time because an update that  
> >> overwrites
> >> existing values with the same values is not that onerous?
> >>
> >> (Is that question clear enough?)
> >
> > I use database table to object mapping classes. The base class sets  
> > a dirty bit if a field actually changes. If an attempt is made to  
> > save the data and no dirty bits are set, then the save method  
> > returns true for a successful save, but no commit to database is  
> > made since nothing has changed. In this way I never think about the  
> > problem beyond the original implementation of the base class.
> 
> Ok, but how do you detect if a field changes? The specific  
> implementation between application and data storage is probably moot  
> until you figure that part out.
> 


If you're worried about how much data needs to be sent back and forth,
then compare the data sent to what exists already on the server side,
and don't send the previous values. To be honest, you can't rely on what
the client says anyway, so you really ought to do the checking
server-side before issuing an update.

Having said that, if you're not too worried about traffic, then sending
the previous values would allow you to give visual indicators to the
user with client-side techniques (javascript, etc) which could be nice
for the user.

Thanks,
Ash
http://www.ashleysheridan.co.uk



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux