简体   繁体   中英

Can't save node after setting its filedcollection DRUPAL

Have such structure: Node -> Filed "field_server_supported_hardware" (Fieldcollection) -> Field "field_hardware_items" (Node reference width checkboxlist)

I want to add one more item in "field_hardware_items" (check one more item in ckeckboxlist).

Here's my code, it doesn't throws errors, but I can't save changes:

$node_wrap = entity_metadata_wrapper('node', $node_id); // our node wrapper

$node_wrap->field_server_supported_hardware[$key_item]->field_hardware_items->offsetSet($new_key, $new_node_item_to_attach);  // setting new item

___save_debug($node_wrap->field_server_supported_hardware[$key_item]->field_hardware_items->value()); // if I log "field_hardware_items", it includes new item, and includes it in correct structure.
$node_wrap->save(TRUE);  // trying to save node

Then I open the node I saved in admins panel, but checkbox of node with id=$new_node_item_to_attach isn't checked.

在保存之前尝试$ node_wrap-> revision-> set(TRUE)显然,save()函数没有考虑在更新时在节点上创建新修订的标志,因此这可能就是为什么您不这样做的原因。看不到变化。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM