I've exposed the privatemsg_list_view() form in my site theme with a bit of work and it's displaying well. However, updating message statuses or trying to delete bulk messages results in a sad error:
An AJAX HTTP error occurred.
HTTP Result Code: 200
Debugging information follows.
Path: /system/ajax
StatusText: OK
ResponseText: Fatal error: Call to undefined function privatemsg_list_submit() in [...]/includes/form.inc on line 1464
Now I know that privatemsg_list_submit() is indeed set as the form #submit handler and I know that it does exist, over in modules/privatemsg/privatemsg.pages.inc
. Obviously there is a disjoint between /system/ajax and my template.
What needs to happen to make this work? Do I just have to attach the .inc file to the form handler somehow? I've tried playing with module_load_include() to no avail.
Suggestions?
Update: The only place I have tried adding the module_load_include()
function is directly before the function call in /includes/form.inc - that would have been somewhere just before line 1464. Obviously that was just a hack for troubleshooting purposes... should the module_load_include()
function be placed somewhere else?
For reference: Call to undefined function privatemsg_list_submit()
Update 2: I have also tried inserting module_load_include()
in a custom module_init() function as well as inside the theme hook_form_alter()
- no luck.
Update 3: Manually including the file within a module_init()
hook makes it work. Here's what it looks like:
function MYMODULE_init(){
if($_GET['q'] == 'system/ajax'){
if ( preg_match('/privatemsg_list/', $_POST['form_id'])) {
include('/great/big/system/path/web/sites/all/modules/privatemsg/privatemsg.pages.inc');
}
}
}
While this appears to work on the surface, I'm sure it's not the right method. Is there a better function hook to use to include this file?
module_load_include()
is indeed the solution, could you add more information about what you've tried with that? – Clive♦ May 11 '13 at 14:37forms.inc
. Should this go in the view or the .tpl.php instead? – emc May 17 '13 at 23:58