Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I've been trying to embed the private message block and may it more user friendly by having the submission take place in ajax form.
1. Its been possible to embed the private message section into the template pages.
2. Not yet been possible to make it ajax based. Any help/support to get this functionality in place as soon as possible.
<?php
module_load_include('pages.inc','privatemsg');
$recipients = array(user_load(arg(1)));
$subject = 'Again, this is just a default that can be changed';
print drupal_render(drupal_get_form('privatemsg_new', $recipients, $subject));
?>
My issue is trying to hook the form to make it ajax based.
http://drupal.org/node/624528#comment-6039804
I tried to hook into the form to build it and adjust the submit button as ajax. Its just not working.
function new_note_form($form, &$form_state, $nodeid = NULL) {
$form_state['build_info']['args'] = array('note');
$form = drupal_build_form('privatemsg_new', $form_state);
$form['submit'] = array(
'#type' => 'button',
'#value' => 'Submit',
'#limit_validation_errors' => array(),
'#ajax' => array(
'callback' => 'advanced_form_callback',
'wrapper' => 'status',
),
);
return $form;
}
Comments
Comment #1
BerdirComment #2
plessas CreditAttribution: plessas commentedThis is my approach on making the form ajax-based, so that the page doesn't reload.
I have created a custom module. This module makes use of hook_form_FORM_ID_alter in order to add the ajax property to the form and define the callback function.
The same approach can be followed for the reply form. However i am not sure how I could load the new message in the thread list after replying without reloading the page.
Comment #3
Coyote6GraphX CreditAttribution: Coyote6GraphX as a volunteer commentedThanks plessas for your answer. Helped me 6 years later. Just an FYI for someone trying to ajax the form in on a separate page, and you are getting an undefined function privatemsg_check_format_accesss() you need to be sure to include the privatemsg.pages.inc on all pages, not just before getting the form. I placed it in the custom module's init function.
Comment #4
ivnish CreditAttribution: ivnish commented