I try to save some data I get into a form in the database but I don't know how to do it.

Currently, here is what I have in the database (I try to add articles). As you can see I already have 2 of them but I set them using directly the CMS. Now I would like to be able to modify these data (for exemple the title of an article) and even add new full articles if possible.


To get the articles this is what I am doing (it works).

    $query = \Drupal::entityQuery('node');
    $query->condition('type', 'Article');
    $items_ids = $query->execute();
    $items = Node::loadMultiple($items_ids);

How do I set the title for the article 2 to title 2 changed?

  • Welcome to Drupal Answers! On the duplicated question, there is an explicit answer about titles, if that is more important for you.
    – apaderno
    Nov 8, 2019 at 14:18
  • Thanks looks like this is what I was looking for. Sorry I'm new to drupal, I would like to extends the question, but it's not really code related I guess. I would like to know if all "entities" are necessarly represented by node. If there is an entity which isn't stored in node I guess we will update with differents methods than the node ones.
    – Minirock
    Nov 8, 2019 at 14:23
  • 1
    @Minirock Nodes are one of Drupal's entity types, users and taxonomy terms are entities as well. It is also possible to create custom entity types, but that can be quite a complicated task if you are new to Drupal :)
    – user72672
    Nov 8, 2019 at 14:26
  • I guess then it makes most of the time more sense to create a new content type (like article) in a node rather than creating a new entity type like node directly ? It's just a little bit confusing to consider all the logic will finally be stored in nodes table.
    – Minirock
    Nov 8, 2019 at 14:36


Browse other questions tagged or ask your own question.