Drupal 7 node_save()仅保存标题

时间:2014-08-19 08:32:31

标签: drupal-7 nodes

我在保存OG内容类型的节点时遇到问题,但我怀疑它是OG内容类型并不是我遇到问题的原因。

我创建了一个名为客户帐户的OG内容类型,字段全部设置,客户端不想使用标准的Drupal UI,因为它太忙而且会引起很多混乱,我有点同意,它更好创建一个表单并获取构成该组的值并保留所有默认的东西,这样客户只看到一个表单。

所以我在这个阶段,节点似乎在提交时被保存,当我在admin / content中查看新创建的内容时,新节点在那里有正确的标题,但是那里不是其他的组值,已经填写的文本框尚未填充,节点仍然不是节点,因为没有保存其他字段数据。

其次,如何将语言类型设置为英语?我尝试将'und'更改为'en'但它仍显示为Undefined()

这是我的代码:

    global $user;
    $node = new stdClass();
    $node->type = 'client_account';
    $node->title = $form_state['values']['groupName'];
    $node->uid = $user->uid;
    $node->name = $user->name;
    $node->comment = 0;
    $node->promote = 0;
    $node->group_group['und'][0]['value'] = 1; //this is a checkbox value on or off
    /*
     * The rest of the fields in the content type are actually text fields
     */
    $node->og_menu = 1;
    $node->field_company_contact['und'][0]['value'] = $form_state['values']['contactName'];
    $node->field_client_email['und'][0]['value'] = $form_state['values']['clientEmail'];
    $node->body = 'set body with page values';
    //not implimented yet but requires a default value
    $node->field_logo['und'][0]['value'] = "/images/logo.png";
    $node->field_website['und'][0]['value'] = $form_state['values']['website'];
    $node->field_address_line_1['und'][0]['value'] = $form_state['values']['addressLine1'];
    $node->field_address_line_2['und'][0]['value'] = $form_state['values']['addressLine2'];
    $node->field_address_line_2['und'][0]['value'] = $form_state['values']['addressLine3'];
    $node->field_region['und'][0]['value'] = $form_state['values']['county'];
    $node->field_region['und'][0]['value'] = $form_state['values']['region'];
    $node->field_post_code['und'][0]['value'] = $form_state['values']['postCode'];
    //Organic groups fields
    $node->og_description = 'A group managed by ' . $user->name;
    $node->og_register = 0;
    $node->og_directory = 1;
    $node->og_private = 1;
    $node->og_selective = 3;
    //create the node
    $node_save = node_submit($node);
    $result = node_save($node_save);
    drupal_goto("accounts");

我已显示$ node_save和$ result的结果,$ node_save已填充,但$ result不是,这是正常的吗?

非常感谢任何帮助或指示

非常感谢

吉姆

1 个答案:

答案 0 :(得分:1)

node_save不会返回值。但是$node_save是通过引用传递的,因此请检查$node_save->nid是否已填充以查看是否已成功保存。