Answers for "drupal 8 programmatically saving node doesn't save custom field values"

0

drupal 8 programmatically saving node doesn't save custom field values

use Drupal\node\Entity\Node;

$my_article = Node::create(['type' => 'article']);
$my_article->set('title', 'My article');
$my_article->set('field_text', 'My text');
$my_article->set('field_image', FID);
$my_article->set('field_user', UID);
$my_article->enforceIsNew();
$my_article->save();
Posted by: Guest on March-03-2021

Code answers related to "drupal 8 programmatically saving node doesn't save custom field values"

Code answers related to "Javascript"

Browse Popular Code Answers by Language