Drupal 7 节点/添加和节点/编辑页面的不同表单覆盖?

Drupal 7 节点/添加和节点/编辑页面的不同表单覆盖?,drupal-7,drupal-forms,Drupal 7,Drupal Forms,Hia 我在一个自定义模块中使用以下内容来自定义我的婴儿内容类型的节点/添加/婴儿页面上的表单,但是,当它位于婴儿内容类型的节点/nid/编辑页面时,我想对此页面进行一些轻微的修改。这可能吗 <code> <?php function concept_theme() { return array( 'baby_node_form' => array( 'arguments' => array( 'form' => N

Hia

我在一个自定义模块中使用以下内容来自定义我的婴儿内容类型的节点/添加/婴儿页面上的表单,但是,当它位于婴儿内容类型的节点/nid/编辑页面时,我想对此页面进行一些轻微的修改。这可能吗

<code>
<?php
function concept_theme() {
  return array(
    'baby_node_form' => array(
      'arguments' => array(
          'form' => NULL,
      ),
      'template' => 'templates/baby-node-form',
      'render element' => 'form',
    ),
  );
}
?>
</code>


谢谢你

你可以通过实现这个钩子来改变节点创建表单, 类似于此:

hook_form_alter(&$form, &$form_state, $form_id) {
  if($form_id == 'node_baby_form') {
     //do modification to form array $form
  }
}

或者,如果您的节点是由hook\u node\u info定义的(我认为不是这样),只需更改hook\u form()中的元素即可通过实现此hook来更改节点创建表单, 类似于此:

hook_form_alter(&$form, &$form_state, $form_id) {
  if($form_id == 'node_baby_form') {
     //do modification to form array $form
  }
}
或者,如果您的节点是由hook\u node\u info定义的(我相信不是这样),只需更改template.php中hook\u form()中的元素即可

function my_theme_name_theme($existing, $type, $theme, $path)
$hooks['baby_node_form']=array(
    'render element'=>'form',
    'template'      =>'templates/node--baby-edit',
);
return $hooks;
}
在节点--baby-edit.tpl.php中

隐藏如下字段:

<?php hide($form['title']); ?>
<?php print render($form['field_image']); ?>

像这样操作字段:

<?php hide($form['title']); ?>
<?php print render($form['field_image']); ?>

使用此选项打印所有/其余内容:

<?php print drupal_render_children($form); ?>

清除template.php中的缓存。

function my_theme_name_theme($existing, $type, $theme, $path)
$hooks['baby_node_form']=array(
    'render element'=>'form',
    'template'      =>'templates/node--baby-edit',
);
return $hooks;
}
在节点--baby-edit.tpl.php中

隐藏如下字段:

<?php hide($form['title']); ?>
<?php print render($form['field_image']); ?>

像这样操作字段:

<?php hide($form['title']); ?>
<?php print render($form['field_image']); ?>

使用此选项打印所有/其余内容:

<?php print drupal_render_children($form); ?>

清除缓存