Make Comments Creation work with fields

I discovered that the comment creation can not handle it when you have comments with fields (in my case a file)

I reworked the way the comment creation works to a more drupal 7 way of problematically creating comments.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

sysosmaster created an issue. See original summary.

sysosmaster’s picture

Title: Make Comments Creation work with fields » Refactor Comment Creation
Issue summary: View changes
sysosmaster’s picture

sysosmaster’s picture

tyler.frankenstein’s picture

Status: Needs review » Postponed (maintainer needs more info)

Comment creation with fields does work, I've used it with many projects. Please share the code/structure you're using when trying to create a comment, as well as what core/contrib fields you are trying to use.

Thank you for the patch, and if we were ever to make a 7.x-4.x branch of Services, your approach would be used. It's unlikely we'll be able to accept that patch though for 7.x-3.x, because we've been using the "forms" approach for many years now.

sysosmaster’s picture

it was not working for files (e.a. you upload a json for a comment service with as the JSON {"Comment":{"nid":"1","cid":0,"pid":0,"uid":7,"language":"und","status":1,"subject":"Processing Result IfcOpenHouse.ifc","is_anonymous":0,"comment_body":{"und":[{"value":"{\"IfcApplication\": \"IfcOpenShell 0.5.0-dev\", \"IfcDoor\": {\"Total amount of IfcDoor elements\": 1}, \"IfcProjectGUID\": \"1234567890\", \"IfcWallStandardCase\": {\"Total amount of IfcWallStandardCase elements\": 4}, \"IfcWindow\": {\"Total amount of IfcWindow elements\": 5}}"}]},"field_result_file":{"und":[{"fid":"66","display":1}]}}}

I do this after I upload the file using the file endpoint.

I made the patch so other can use it allthough i totally agree to wait for the 7.x-4.x release for this approach (if we ever get one).

tyler.frankenstein’s picture

Your JSON data looks fine, except for the "comment_body" value looks pretty strange.

P.S. Maybe try removing the "display" property from your file JSON object too.

sysosmaster’s picture

All of it works except for the field_result_file, that gets lost completely by the form handler somewhere (could not pinpoint it completely with my debugger). I suspect it is a similar problem as attaching files to node's. the form simply silently drops the file attaching.

tyler.frankenstein’s picture

Interesting. In a case like this, I'm starting to think that a contrib/custom module on your site may be "form altering" that particular field during Services calls. Do you see any potential suspects in your module list?

Otherwise I'm very certain that attaching file ids to nodes and comments is working properly, I use both currently in a few different apps. This patch may be useful to: #2224803: Possible patch for multi-value fields

kylebrowning’s picture

Status: Postponed (maintainer needs more info) » Closed (works as designed)

Yeah we use form submit to get all the benefits of the hook system, this is a wont fix.