2

On every user profile page i have a tab My company its a node edit form of content type Company. Here the code:

/**
 * Implementation of hook_menu().
 */
function feature_directory_section_menu(){
  $items = array();

  $items['user/%user/company'] = array(
    'title' => 'My company',
    'page callback' => 'feature_directory_section_user_company',
    'page arguments' => array(1),
    'access callback' => 'feature_directory_section_access_user_company',
    'access arguments' => array(1),
    'type' => MENU_LOCAL_TASK,
    'weight' => 10,
  );

  return $items;
}
//callback function
function feature_directory_section_user_company($account) {
  $uid = is_object($account) ? $account->uid : (int) $account;
  module_load_include('inc', 'node', 'node.pages');
  $output = '';
  $nid = db_query("SELECT n.nid FROM {node} n WHERE n.uid = :uid", array(':uid'=> $uid))->fetchField();

  if (is_numeric($nid)) {
    $output = node_page_edit(node_load($nid));
  } else {
    $output = t('You have no company. Please contact the site administrator.');
  }

  return $output;
}

Content type company has alot of fields, when i trying to edit node on user/%user/company page everything works fine, but one thing not working its ajax image upload or i can't delete image of my field(field_company_gallery) - its just a image field and u can upload unlimited count of images.

I get a lot of errors. If i go to node/%nid/edit i can manage images. but on user profile tab i can't.

Some errors are next:

Warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'node_form' not found or invalid function name in drupal_retrieve_form() (line 798 of /home/www/buildit/htdocs/includes/form.inc).
Notice: Undefined index: #node in comment_form_node_form_alter() (line 1194 of /home/www/buildit/htdocs/modules/comment/comment.module).


Notice: Undefined index: field_company_gallery in file_ajax_upload() (line 271 of /home/www/buildit/htdocs/modules/file/file.module).
Notice: Undefined index: #suffix in file_ajax_upload() (line 280 of /home/www/buildit/htdocs/modules/file/file.module).

I guess i need to load all the modules with this function module_load_include or maybe not, i am stuck here.

1

Ok i found solution:

If your node form has a file upload widget, you should add this code to hook_menu.

'file path' => drupal_get_path('module', 'node'),
'file' => 'node.pages.inc',

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.