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
Have you set a column in your table to 'unique'? That should generate unique ids for each of the update fields.
#2
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
#3
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
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
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
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
subscribe
#8
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.