Drupal 7 节点表单提交在ctools模型中不起作用

Drupal 7 节点表单提交在ctools模型中不起作用,drupal-7,drupal-ctools,Drupal 7,Drupal Ctools,我创建了一个ctools模型来打开具有字段集合的节点表单。 我试图保存表单,它显示错误 function bayerkol_callback($ajax) { if ($ajax) { global $user; ctools_include('ajax'); ctools_include('modal'); $form_state = array( 'ajax' => TRUE, 'title' => t('Add Event'), ); $output = cto

我创建了一个ctools模型来打开具有字段集合的节点表单。 我试图保存表单,它显示错误

function bayerkol_callback($ajax) {
if ($ajax) {
  global $user;
ctools_include('ajax');
ctools_include('modal');

$form_state = array(
  'ajax' => TRUE,
  'title' => t('Add Event'),
);

$output = ctools_modal_form_wrapper('bayerkol_form', $form_state);

if (!empty($form_state['ajax_commands'])) {
  $output = $form_state['ajax_commands'];
}

print ajax_render($output);
drupal_exit();
}
else {
return drupal_get_form('event_calendar_node_form');
}
}   

function bayerkol_form($form, $form_state) {
$form = array();
ctools_form_include_file($form_state, drupal_get_path('module', 'node') . '/node.pages.inc');
$form = node_add('event_calendar');
return $form;
} 

请帮帮我。

试试我下面的代码,希望能奏效

function bayerkol_callback($ajax) {
  if ($ajax) {
     global $user;

     ctools_include('node.pages', 'node', '');
     ctools_include('modal');
     ctools_include('ajax');

     $node = (object) array(
         'uid' => $user->uid,
         'name' => (isset($user->name) ? $user->name : ''),
         'type' => 'article',
         'language' => LANGUAGE_NONE,
     );

     $form_state = array(
         'ajax' => TRUE,
         'title' => t('Add Event'),
     );

     $form_state['build_info']['args'] = array($node);

     $output = ctools_modal_form_wrapper('bayerkol_form', $form_state);

     // This means the form has been exectued
     if (!empty($form_state['executed'])) {
         $output = array();
         // Close the modal
         $output[] = ctools_modal_command_dismiss();
     }

    print ajax_render($output);
    exit;
  }else {
         return drupal_get_form('event_calendar_node_form');
   }
  }
在上面的代码中,不需要调用bayerkol_form函数。确保您的节点形式是正确的示例:对于文章,请使用{article\u node\u form}