Followed this to http://drupal.org/node/1354202 to add files with node.create. It works for me to create, but if I follow the same method for adding new files to my node on update, they will only be created (added to file_managed) but not connected to the node. But if I update title or description on an existing file it will be updated. It seems like you only can specify fid for the files when creating, not updating. It will skip those files.
It seems like the form_builder method strips the field_files from the new files when I do node.update?
Here is the array for the PUT. fid 185 was added one node.create and here I changed the title and the title for that file is updated. But the other file which is new for the update request, it is not added to the node when updated. Any ideas? Do I need to set a flag on the node or the field for it to store "new files"?
[field_files] => Array
(
[und] => Array
(
[0] => Array
(
[fid] => 185
[display] => 1
[title] => My name
[description] =>
)
[1] => Array
(
[fid] => 186
[display] => 1
[title] =>
[description] => My description
)
)
)| Comment | File | Size | Author |
|---|---|---|---|
| #14 | services-node_user_updates_ignore_new_files-1433254-14.patch | 1.42 KB | ruloweb |
| #11 | user.update_fid_fix-1433254-11.patch | 798 bytes | lex0r |
Comments
Comment #1
kylebrowning commentedComment #2
drewschmaltz commentedworkaround:
Comment #3
jyloo commentedwow, i used a whole night trying to troubleshoot this problem until i found your code here.Work like charm!!
Now my update page can delete and add in new item well.
thanks.
btw if i use this code, would the field still perform the validation part correctly?
Comment #4
farhadhf commentedHi,
I'm having the same problem, where should I put the code in #2? I have this code right now:
but it's not working.
Thanks!
Comment #5
emilkarl commentedMy guess is you should update the node resource in Services module...
File: services/resources/node_resource.inc
Function: _node_resource_update
Line: No idea?
Comment #6
emilkarl commentedWhere should this go? Is it fixed in 7.x-3.3?
Comment #7
farhadhf commentedHi,
I changed my code and now it's working, maybe this will help someone later!
Comment #7.0
farhadhf commentedMore accurate description
Comment #8
wedge commentedFor the archives: I put the code from #2 (thanks drewschmaltz) right before the call to
drupal_form_submit($node_type . '_node_form', $form_state, $old_node);in _node_resource_update().And that seems to work.
Comment #9
lex0r commentedI can't believe this major issue is still active and without a patch :)
I can confirm I see the same situation with user.update, which can promote this issue to "critical". I will post a patch for user.update here later.
Comment #10
lex0r commentedComment #11
lex0r commentedHere is a patch for 7.x-3.11 that handles user file updates. Use it very cautiously as it's not a proper way of fixing the issue. It was impossible to bind to hook_user_submit() like above, because this hook just doesn't exist.
Comment #12
kylebrowning commentedComment #13
kylebrowning commentedYeah this patch only works for user update, we need it for nodes too....
Comment #14
ruloweb commentedHi guys, I spended a lot of time debugging this issue and these contributions help me to solve it.
I created a patch which merges #2 and #11, it applies on 3.x-dev and 3.12.
Thanks!
Comment #15
kylebrowning commentedComment #16
kylebrowning commentedCan anyone verify this latest patch works?
Comment #17
kylebrowning commentedDude to this being label as use cautiously, and no support for a new patch, closing as wont fix.