📜  drupal 8 以编程方式保存节点不保存自定义字段值 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:03:38.340000             🧑  作者: Mango

代码示例1
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();