Hi there,

I've added a filefield to the private message form, and I'm trying to embed the form programmatically somewhere on my site. I've used this code:

module_load_include('pages.inc','privatemsg');
$to_uid = 3;
$subject = 'Something';
print drupal_render(drupal_get_form('privatemsg_new', $to_uid, $subject));

It all works fine except when I click the "upload" button for a file. Then I get some AJAX error that includes this:

"call to undefined function privatemsg_check_format_access()"

If I don't try to upload the file via AJAX and just submit the form it works fine, so it's only when there's an AJAX call. I guess the required files are not included.

Thank you for any advice!

Hubert.

Comments

gzveri’s picture

Here's the solution :

create a custom module and use hook form alter,
and form_load_include to include the required file (privatemsg.pages.inc)

function mymodule_form_alter(&$form, &$form_state, $form_id) {
	switch ($form_id) {
		case 'privatemsg_new':
			form_load_include($form_state, 'inc', 'privatemsg', 'privatemsg.pages');
			//...... here some form alteration code
			break;
  }
}

oh, and don't forget to clear the cache

j.b’s picture

Thanks #1
works

ptmkenny’s picture

Status: Active » Closed (fixed)
ptmkenny’s picture

Issue summary: View changes

better formatting

ggive’s picture

Issue summary: View changes

Solution working fine