Drupal 6 drupal\u get\u表单未传递节点数组

Drupal 6 drupal\u get\u表单未传递节点数组,drupal-6,drupal-modules,Drupal 6,Drupal Modules,我无法让drupal\u get\u表单传递节点数据。下面是代码片段。drupal_get_表单文档(api.drupal.org)声明它将传递额外的参数。我之所以不传递节点数据,是因为(显然)$node['language']没有在hook_表单中定义,这会导致$form['qqq']无法创建,因此会显示预览按钮 我的目标是预览按钮使用路径“node/add/author”显示,但不显示“milan/author/add”。实现这一目标的任何替代方法都会有所帮助,但我想回答的问题在前一段。我所

我无法让drupal\u get\u表单传递节点数据。下面是代码片段。drupal_get_表单文档(api.drupal.org)声明它将传递额外的参数。我之所以不传递节点数据,是因为(显然)$node['language']没有在hook_表单中定义,这会导致$form['qqq']无法创建,因此会显示预览按钮

我的目标是预览按钮使用路径“node/add/author”显示,但不显示“milan/author/add”。实现这一目标的任何替代方法都会有所帮助,但我想回答的问题在前一段。我所读到的一切都表明它应该有效

此菜单项

$items['milan/author/add'] = array( 'title' => 'Add Author', 'page callback' => 'get_author_form', 'access arguments' => array('access content'), 'file' => 'author.pages.inc', ); $items['milan/author/add']=数组( “标题”=>“添加作者”, “页面回调”=>“获取作者表单”, “访问参数”=>数组(“访问内容”), '文件'=>'author.pages.inc', ); 调用此代码

function get_author_form() { //return node_form(NULL,NULL); //return drupal_get_form('author_form'); return author_ajax_form('author'); } function author_ajax_form($type) { global $user; module_load_include('inc', 'node', 'node.pages'); $types = node_get_types(); $type = isset($type) ? str_replace('-', '_', $type) : NULL; // If a node type has been specified, validate its existence. if (isset($types[$type]) && node_access('create', $type)) { // Initialize settings: $node = array('uid' => $user->uid, 'name' => (isset($user->name) ? $user->name : ''), 'type' => $type, 'language' => 'bbb','bbb' => 'TRUE'); $output = drupal_get_form($type .'_node_form', $node); } return $output; } 函数get\u author\u form(){ //返回节点形式(空,空); //返回drupal_get_form('author_form'); 返回author_ajax_表单(“author”); } 函数作者\u ajax\u表单($type){ 全球$用户; 模块加载包括('inc','node','node.pages'); $types=node_get_types(); $type=isset($type)?str_replace('-','',$type):NULL; //如果已指定节点类型,请验证其存在性。 if(isset($types[$type])&节点访问($create',$type)){ //初始化设置: $node=array('uid'=>$user->uid,'name'=>(isset($user->name)?$user->name:''),'type'=>$type,'language'=>'bbb','bbb'=>TRUE'); $output=drupal\u get\u form($type.“\u node\u form”,$node); } 返回$output; } 这是hook形式和hook形式转换代码

function author_form_author_node_form_alter(&$form, &$form_state) { $form['author']=NULL; $form['taxonomy']=NULL; $form['options']=NULL; $form['menu']=NULL; $form['comment_settings']=NULL; $form['files']=NULL; $form['revision_information']=NULL; $form['attachments']=NULL; if($form["qqq"]) { $form['buttons']['preview']=NULL; } } function author_form(&$node) { return make_author_form(&$node); } function make_author_form(&$node) { global $user; $type = node_get_types('type', $node); $node = author_make_title($node); drupal_set_breadcrumb(array(l(t('Home'), NULL), l(t($node->title), 'node/' . $node->nid))); $form['authorset'] = array( '#type' => 'fieldset', '#title' => t('Author'), '#weight' => -50, '#collapsible' => FALSE, '#collapsed' => FALSE, ); $form['author_id'] = array( '#access' => user_access('create pd_recluse entries'), '#type' => 'hidden', '#default_value' => $node->author_id, '#weight' => -20 ); $form['authorset']['last_name'] = array( '#type' => 'textfield', '#title' => t('Last Name'), '#maxlength' => 60, '#default_value' => $node->last_name ); $form['authorset']['first_name'] = array( '#type' => 'textfield', '#title' => t('First Name'), '#maxlength' => 60, '#default_value' => $node->first_name ); $form['authorset']['middle_name'] = array( '#type' => 'textfield', '#title' => t('Middle Name'), '#maxlength' => 60, '#default_value' => $node->middle_name ); $form['authorset']['suffix_name'] = array( '#type' => 'textfield', '#title' => t('Suffix Name'), '#maxlength' => 14, '#default_value' => $node->suffix_name ); $form['authorset']['body_filter']['body'] = array( '#access' => user_access('create pd_recluse entries'), '#type' => 'textarea', '#title' => 'Describe Author', '#default_value' => $node->body, '#required' => FALSE, '#weight' => -19 ); $form['status'] = array( '#type' => 'hidden', '#default_value' => '1' ); $form['promote'] = array( '#type' => 'hidden', '#default_value' => '1' ); $form['name'] = array( '#type' => 'hidden', '#default_value' => $user->name ); $form['format'] = array( '#type' => 'hidden', '#default_value' => '1' ); // NOTE in node_example there is some addition code here not needed for this simple node-type $thepath='milan/author'; if($_REQUEST["theletter"]) { $thepath .= "/" . $_REQUEST["theletter"]; } if($node['language']) { $thepath='milan/authorajaxclose'; $form['qqq'] = array( '#type' => 'hidden', '#default_value' => '1' ); } $form['#redirect'] = $thepath; return $form; } 函数author\u form\u author\u node\u form\u alter(&$form,&$form\u state){ $form['author']=NULL; $form['taxonomy']=NULL; $form['options']=NULL; $form['menu']=NULL; $form['comment_settings']=NULL; $form['files']=NULL; $form['revision_information']=NULL; $form['attachments']=NULL; 如果($form[“qqq”]){ $form['buttons']['preview']=NULL; } } 函数作者表单(&$node){ 返回make_author_表单(&$node); } 函数make_author_表单(&$node){ 全球$用户; $type=node\u get\u types('type',$node); $node=作者名称($node); drupal_set_breadcrumb(数组(l(t('Home'),NULL),l(t($node->title),'node/'.$node->nid)); $form['authorset']=数组( “#类型”=>“字段集”, “#title”=>t(“作者”), “#重量”=>-50, “#可折叠”=>错误, “#崩溃”=>错误, ); $form['author_id']=数组( “#访问”=>user_访问('create pd_recluse entries'), “#类型”=>“隐藏”, “#默认值”=>$node->author\u id, “#重量”=>-20 ); $form['authorset']['last_name']=array( “#键入”=>“文本字段”, “#title”=>t(‘姓’), “#maxlength”=>60, “#默认值”=>$node->last_name ); $form['authorset']['first_name']=array( “#键入”=>“文本字段”, “#title”=>t(“名字”), “#maxlength”=>60, “#默认_值”=>$node->first_name ); $form['authorset']['middle_name']=array( “#键入”=>“文本字段”, “#title”=>t(中间名), “#maxlength”=>60, “#默认_值”=>$node->中间_名称 ); $form['authorset']['suffix_name']=array( “#键入”=>“文本字段”, “#title”=>t(‘后缀名’), “#maxlength”=>14, “#默认_值”=>$node->后缀_名称 ); $form['authorset']['body\u filter']['body']=array( “#访问”=>user_访问('create pd_recluse entries'), “#键入”=>“文本区域”, “#title”=>“描述作者”, “#默认值”=>$node->body, “#必需”=>错误, “#重量”=>-19 ); $form['status']=数组( “#类型”=>“隐藏”, “#默认_值”=>“1” ); $form['promote']=数组( “#类型”=>“隐藏”, “#默认_值”=>“1” ); $form['name']=数组( “#类型”=>“隐藏”, “#默认值”=>$user->name ); $form['format']=数组( “#类型”=>“隐藏”, “#默认_值”=>“1” ); //注意,在node_示例中,这里有一些简单节点类型不需要的附加代码 $thepath='milan/author'; 如果($_请求[“字母”]){ $thepath.=“/”$\u请求[“theletter”]; } if($node['language'])){ $thepath='milan/authorajaxclose'; $form['qqq']=数组( “#类型”=>“隐藏”, “#默认_值”=>“1” ); } $form['#redirect']=$thepath; 返回$表格; } 该菜单路径与此主题一致(PHPTemplate)


可能不是这样,但我看到您在
make\u author\u form()
方法中首先将
$node
用作对象(标题),然后用作数组(获取语言)。如果
$node
是一个对象,那么这就解释了为什么不能检索
$node['language']

不确定我是否完全理解您试图做的事情,但我认为使用页面参数是一个好主意

function mymodule_form_alter($form_id, &$form) {
  // If $form_id is {node->type}_node_form
  // Then, check for the first argument in the URL and hide/show Preview accordingly
}

原来是make_author_form函数第4行中的一个基本编程错误。我自己正在调零$node变量。

这不是个坏主意,但不是问题所在。这就是反复重写特定代码所积累的积垢。
function mymodule_form_alter($form_id, &$form) {
  // If $form_id is {node->type}_node_form
  // Then, check for the first argument in the URL and hide/show Preview accordingly
}