Update field value not correct

Code Rader - January 4, 2008 - 21:05
Project:Ajax Table
Version:5.x-1.0
Component:Code
Category:bug report
Priority:critical
Assigned:Unassigned
Status:needs review
Description

Whenever you update a field, it goes to the right record, but not with the right value. It uses the first value of the page. This appears to be because the inputs don't appear to have unique ids, so the javascript pulls the value from the first id.

This is pretty important though and needs to be addressed ASAP. I'll work on a patch myself.

#1

chrisshattuck - January 4, 2008 - 21:13

Have you set a column in your table to 'unique'? That should generate unique ids for each of the update fields.

#2

Code Rader - January 4, 2008 - 21:46
Status:active» needs review

I tried it on example4 from the docs and when I tried to update the last row, it sent the value from the top row and the saved indicator was for the top row.

This patch seems to fix it though

AttachmentSize
update.patch 851 bytes

#3

chrisshattuck - January 4, 2008 - 22:07

There were a couple problems that I have fixed in the docs module for that example:

1. A 'unique' column was not set. It is set now.
2. A input column function for the date was set inside another function, so it wasn't working properly. This has been fixed.

I took a look at that patch, and I think it's probably not a good idea. It just changes the where the loading indicator is displayed, but this covers up the problem of not having a 'unique' column set. Without that column set, then the problem you were experiencing where if you update one row, it applies it to the wrong entry, will still be happening.

#4

Code Rader - January 4, 2008 - 22:24

the patch also changed the input_id, not just the loading_id - it appends the unique id of the row to the input id and to the loading id.

+       $loading_id = $js_function_name . '_loading'.$input['uid'];
+       $input_id = $js_function_name . '_input'.$input['uid'];

#5

chrisshattuck - January 4, 2008 - 22:47

Ah, true! The 'unique' column parameter solution works, That made me look at that bit of code a bit more, and I see that since an input column requires a 'uid' parameter, that I can just remove the 'unique' parameter all together. So, instead of your patch, I changed the $row[$table['unique_col_clean']] to $input['uid'] in the line that starts with "$id =" right above where your patch would apply. That should fix it.

Thanks!

#6

victorwong - January 9, 2008 - 01:21

Thanks for referring to this from http://drupal.org/node/206254. I've updated the example 4 with the patch recommended and use Firefox to load the page. The Error Console comes up with the warning "Error in parsing value for property 'display'. Declaration dropped"

The update is still not working. Same popup comes up. Any ideas to fix? Thanks a lot.

#7

baja_tz - January 9, 2008 - 14:02

subscribe

#8

chrisshattuck - January 10, 2008 - 01:28

victorwong - I have made some updates that should fix this and committed them to cvs. They should be available the next time a snapshot runs, or you can grab DRUPAL-5 from cvs.

 
 

Drupal is a registered trademark of Dries Buytaert.