Postponed
Project:
Reply
Version:
7.x-1.x-dev
Component:
User interface
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
14 Apr 2012 at 00:56 UTC
Updated:
26 Feb 2017 at 12:52 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
Anonymous (not verified) commentedIt's not hard at all but currently it's not in to do list.
Comment #2
rogical commentedAJAX Comments, Inline Ajax Comments this two modules can work for you.
For this module, we can plan to integrate with nodejs in the future.
Comment #3
eidoscomHi here,
I'm trying to configure the reply form as an AJAX form in order to let the user post a Reply and reload the page with AJAX. Make the form controlled with AJAX is easy, you only need to add this code to reply_add_form() function on reply.module file:
Where 'callback' tells the Form system what callback should be called after the AJAX call happens and the form is rebuilt, and the 'wrapper' is the HTML ID of a page section that should be replaced (or altered in some other way).
The modules commented on #2 are not working with Reply because are focuset on the drupal core comment system. So we need an alternative...
All that I have done let the form submitted by AJAX, but I need to have the new "replies set" to output via the callback function. I'm trying to use the 'reply_build_content' function but the system throws me an error :
Anny suggestion??
Comment #4
james.williamsCan you post here the contents of your
reply_submit_js()function?Comment #5
eidoscomAt the moment, all that i Have is this:
Comment #6
james.williamsCheck the
reply_build_content()parameters:You need to pass the full reply entity, not just its ID.
Comment #7
eidoscomThis is my personalized replies.tpl.php in order to understand the "replies-wrapper-id" selector.
Thanks!
Comment #8
eidoscomYes, I know that is not enough with the entity_id extracted from form, moreover, this entity_id is refered to the entity that have the replies attached to ... Can I get the object from this id?? how?
Comment #9
james.williamsYou can load a reply with
reply_load($reply_id). However I'm not sure the reply itself will actually be available to you, in$form_stateor anywhere else.I see comment module has this line:
$form_state['values']['cid'] = $comment->cid;incomment_form_submit(). You may wish to add something similar in ourreply_add_form_submit()so that you can access the created reply.Comment #10
eidoscomAs I understand, I need to recreate the array of replies attached to the entity that has the "entity_id" in order to render again and replace the old data with the new data.
I think that is the same that module do when an entity that have "Reply enabled" is rendered... I think that the module must use the 'entity_id' like I need here, but I can't find where in the code can get this actions ....
Still searching for the solution.
Comment #11
james.williamsAh okay I misunderstood what you are trying to do.
The reply module would normally display replies on an entity through a field formatter,
reply_field_formatter_view(). So what you actually want to do is just display your reply field on the parent entity (assuming your field instance settings work in this way). Try calling field_view_field(). For example:Comment #12
eidoscomHi James,
First of all thanks for your quick support ;)
I think that I'm not explaining well what I want to do :S
I'm trying to manage the replies with AJAX. I configured As I posted above (#3), the form is submitting via AJAX with no other problems. The database gets the right values. I need to refresh the reply list (replies) with the new one in order to show the recent changes of the replies
I can do by two ways:
I want to have 1 or 2 in a string format in order to output via AJAX.
Sorry about my English I do my best ...
Comment #13
eidoscomI tried your last code and throws me another error:
The entity of type Message is the entity that has the "field_comentarios" reply field.
Comment #14
eidoscomOkay!!
It seems that I did it!!
This is the code for the callback function.
Now it's working !!
Comment #15
eidoscomHi again
This is working well, but the Reply form still has the old values... And moreover, the new form is not processing by AJAX.
I use the reply_add_form() to build the form where I added this:
I think that if I use the reply_add_form() function to build the new form, the AJAX class must be attached to the new form, but this is not working...
Here is the code that I use as ajax callback:
Some idea about this??
Comment #16
achilles085 commented@eidoscom did you manage to get the solution?
Comment #17
eidoscomNope....
With the code above you can submit the replies via AJAX but only the first one... If you try to submit a second one is not AJAX processed and if you add some extra fields like images the files are correctly submited but not showing well in the AJAX created new reply .... I think this last is because must define some waiting time until the file is uploaded
It's a little wired and I'm not working on it at the moment ... If you get this code and the problems that I posted here you can try to continue ;)
Comment #18
churel commented@eidoscom and @achilles085 :
I have the same problem. Your code is ok but you need to rebuild the form before send it by ajax (without that no form_alter etc...). What you need to do is :
and it work.
Comment #19
adamtong commentedHi, can you tell me where to add the code in the files? And what is the most updated code should I add?
Thank you in advance.
Comment #20
adamtong commentedI have tried to add the code. But there is a bug that the reply submitted twice after reload the page.
I add the following code at around line 986:
And this code after
return $form;
}
Attached is the reply.module I changed
Please help.
Thank you in advance.
Comment #21
niallmurphy-ie commentedHas anyone ever gotten Ajax to work?
Edit: Nevermind, I took the code here and somehow adapted it to the 7.x-2.x-dev code and it's working
finewith errors. I'll post it tomorrow.