For a multilanguage-project I have to disable the standard node/add form (and URLs). Therefore, as I did before in another project, I provide these forms in an admin-overlay by a custom module:

<?php

function module_menu() {
  $items = array();

  // For each node type:
  $items['admin/content/[node_type]/add'] = array(
      'title'            => t('Add @node_type', array('@node_type' => t('Node Type'))),
      'page callback'    => 'drupal_get_form',
      'page arguments'   => array('module_node_add_form', 'node_type'),
      'access arguments' => array('administer nodes'),
      'file path'        => drupal_get_path('module', 'node'),
      'file'             => 'node.pages.inc',
      'type'             => MENU_LOCAL_TASK,
      'weight'           => 1,
      );

  return $items;
}

function module_node_add_form ($form, &$form_state, $node_type) {
  module_load_include('inc', 'node', 'node.pages');
  return node_add($node_type);
}

?>

This worked fine in a non-multilanguage environment. With Entity Translation enabled and field translations in these respective nodes, an error is thrown while form validation:

Fatal error: Call to a member function entityFormValidate() on a non-object in [My Project Path]\sites\all\modules\entity_translation\entity_translation.module on line 1414

I consider this an error caused by Entity Translation and would appreciate any help to avoid it.

CommentFileSizeAuthor
#1 et-null_handler_validate-1972482-1.patch570 bytesplach

Comments

plach’s picture

Version: 7.x-1.0-beta2 » 7.x-1.x-dev
Status: Active » Needs review
StatusFileSize
new570 bytes

What about this?

mario steinitz’s picture

Well, I "applied" this patch manually without effort. The error changed to an 'The website encountered an unexpected error. Please try again later.'-error with the following details:

  • Notice: Undefined index: node in node_form_submit_build_node() (line 507 of [My Drupal Installation]\modules\node\node.pages.inc).
  • EntityMalformedException: Missing bundle property on entity of type node. in entity_extract_ids() (line 7663 of [My Drupal Installation]\includes\common.inc).
plach’s picture

I'm sorry but #2 does not look immediately related to ET. I am happy to commit #1, but for anything else I need steps to reproduce an error in ET or a patch with an explanation of what is causing the issue and how the patch is fixing it (see http://drupal.org/project/entity_translation#bugfixing).

mario steinitz’s picture

Status: Needs review » Closed (fixed)

Found a solution for my issue and replaced

function module_node_add_form ($form, &$form_state, $node_type) {
  module_load_include('inc', 'node', 'node.pages');
  return node_add($node_type);
}

with

function module_node_add_form ($form, &$form_state, $node_type) {
  global $user;
  module_load_include('inc', 'node', 'node.pages');
  $node = (object) array(
      'uid' => $user->uid,
      'name' => (isset($user->name) ? $user->name : ''),
      'type' => $node_type,
      'language' => LANGUAGE_NONE,
      );
      
  node_object_prepare($node);
  $form_state['build_info']['args'] = array($node);
  
  $form = drupal_retrieve_form($node_type . '_node_form', $form_state);
  drupal_prepare_form($node_type . '_node_form', $form, $form_state);

  return $form;
}

Now it works like a charm and does not seem to be an Entity Translation bug rather than a bug in the node module or drupal_get_form.

Thanks for your help anyway!

plach’s picture

Status: Closed (fixed) » Reviewed & tested by the community

The patch in #1 looks good anyway.

plach’s picture

Status: Reviewed & tested by the community » Fixed

Committed and pushed.

Status: Fixed » Closed (fixed)

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