Hi,

I used the following code for retrieving a node create/edit form inside a block

$node = node_load(arg(1));
module_load_include('inc', 'node', 'node.pages');
return drupal_get_form($node->type .'_node_form', $node);

And i got an error alert message of "Invalid response from server". Then I dived a bit into the code and found that inside hierarchical_select.module:287
some parameters are being loaded from the cache - from a Dynamic form_id. My missing parameter is $storage['file'] = 'modules/node/node.pages.inc'; hierarchical_select.module:302.
I added it manually and it works fine now. I didn't find a way to pass this parameter.
My solution for my case is to add the node.pages.inc file if $storage['file'] is empty. I didn't find a way to pass this file parameter externally.
I attached a patch with my change, tell me please if there's other solution.

CommentFileSizeAuthor
hierarchical_select.module.patch547 bytesshua

Comments

wim leers’s picture

Category: task » support
Status: Patch (to be ported) » Fixed

You almost found it. It's the same as for CTools:

  // Also include files set in $form_state['form_load_files']. Set by CTools
  // Delegator, which is used by Panels (i.e. this is necessary for Panels
  // compatibility).
  if (isset($form_state['form_load_files'])) {
    foreach ($form_state['form_load_files'] as $file) {
      require_once './' . $file;
    }
  }

So you should do this in your form code:

$form_state['form_load_files'] = array(drupal_get_path('module', 'node') . '/pages.inc');

Then it should work.

shua’s picture

Thanks

wim leers’s picture

Title: Hierarchical Taxonomy doesn't work for node create/edit form where the form is not in node create/edit page (like node/add/*) » Document CTools' $form_state['form_load_files'] compatibility
Component: Code - Taxonomy » Code
Assigned: Unassigned » wim leers
Category: support » task
Status: Fixed » Needs work

You're welcome :)

This needs to be documented better.

Bilmar’s picture

subscribing

wim leers’s picture

Status: Needs work » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

ahallez’s picture

Issue summary: View changes

Hi all,

It is not clear to me where exactly this should be added.
I added $form_state['form_load_files'] = array(drupal_get_path('module', 'ip') . 'ip/r2s.injury.inc');
in the function that builds the form, but it doesn't work.

When I check the $form_state that is available in hierarchical_select_json(), it doesn't have this entry, so the file is not included.
Where do I put the code such that the information is available in the json call back?