Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/drupal/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
drupal:自定义内容类型字段#默认值不显示_Drupal - Fatal编程技术网

drupal:自定义内容类型字段#默认值不显示

drupal:自定义内容类型字段#默认值不显示,drupal,Drupal,我正在学习drupal,学习一个创建自定义内容类型的模块。一切正常。我可以添加和更新自定义节点。唯一不起作用的是,当我编辑节点时,两个自定义字段的#default_值不会显示。这是我的表格: function mymodule_form(&$node, $form_state) { $type = node_get_types('type', $node); $form['title'] = array( '#type' => 'textfield',

我正在学习drupal,学习一个创建自定义内容类型的模块。一切正常。我可以添加和更新自定义节点。唯一不起作用的是,当我编辑节点时,两个自定义字段的#default_值不会显示。这是我的表格:

function mymodule_form(&$node, $form_state) {
  $type = node_get_types('type', $node);
  $form['title'] = array(
        '#type' => 'textfield',
        '#title' => check_plain($type->title_label),
        '#required' => TRUE,
        '#default_value' => $node->title,
        '#weight' => -5,
    );
    $form['body'] = array(
    '#type' => 'textarea', 
    '#title' => check_plain($type->body_label), 
    '#rows' => 20, 
     '#default_value' => $node->body,
    '#required' => TRUE,
  );
  $form['other'] = array(
    '#type' => 'textfield', 
    '#title' => t('Other thingy'), 
    '#default_value' => $node->other, 
  );
  if ($node->type == 'chucky') {
    $form['other2'] = array(
        '#type' => 'textfield', 
        '#title' => t('Other thingy 2'), 
        '#default_value' => $node->other2, 
      );
  }
  return $form; 
}

因此,这两个自定义字段是other和other2,这些列位于mymodule表中,我可以添加和更新它们的值。但是它们不会在编辑表单中重新显示为默认值。

对不起,我应该在下面的教程中进一步阅读。显然,在使用hook_load()检索自定义字段之前,这些字段不是节点对象的一部分。现在一切正常