Question
How to create a node programmatically in Drupal 8 ?
Here an example for create node programmatically in Drupal 8
Node type : article$language = \Drupal::languageManager()->getCurrentLanguage()->getId();
$node = \Drupal\node\Entity\Node::create(array(
'type' => 'article',
'title' => 'The title',
'langcode' => $language,
'uid' => 1,
'status' => 1,
'body' => array('The body text'),
'field_date' => array("2000-01-30"),
//'field_fields' => array('Custom values'), // Add your custon field values like this
));
$node->save();
Comments
PHP Fatal error: Call to…
PHP Fatal error: Call to undefined function Drupal\file\Plugin\Field\FieldType\file_default_scheme() in core/modules/file/src/Plugin/Field/FieldType/FileItem.php on line 39
Please send me your codes…
Please send me your codes and full details.
Add new comment