2

I have a custom content type and want to create new nodes in code. The content type contains fields, some will be set with values and others left empty. Is it necessary to define all the fields using $node->field_custom_name[$node->language][0]['value'] = 'field value'; or just the ones with values to complete the node definition?

1 Answer 1

2

You can happily omit the empty ones, there's no problem. When consulting the newly created node, node_load() will retrieve all the attached field and build the correct object.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.