Update a content type field via db not working D8 I have a content type field with machine name field_p_frontip and for that i have a table node__field_p_frontip and in that there is field value like field_p_frontip_value . Eventhough i manually inserted a value in to that field its not taking effect in the front end . I updated the value in the node_revision__field_p_frontip table too and cleared the cache .Why its not working ,any idea ?

I done this because i done via hook_form_alter and its not taking effect .

node__field_p_frontip table structre : 

+-----------------------+------------------+------+-----+---------+-------+
| Field                 | Type             | Null | Key | Default | Extra |
+-----------------------+------------------+------+-----+---------+-------+
| bundle                | varchar(128)     | NO   | MUL |         |       |
| deleted               | tinyint(4)       | NO   | PRI | 0       |       |
| entity_id             | int(10) unsigned | NO   | PRI | NULL    |       |
| revision_id           | int(10) unsigned | NO   | MUL | NULL    |       |
| langcode              | varchar(32)      | NO   | PRI |         |       |
| delta                 | int(10) unsigned | NO   | PRI | NULL    |       |
| field_p_frontip_value | longtext         | NO   |     | NULL    |       |
+-----------------------+------------------+------+-----+---------+-------+


and node_revision__field_p_frontip table structure :

+-----------------------+------------------+------+-----+---------+-------+
| Field                 | Type             | Null | Key | Default | Extra |
+-----------------------+------------------+------+-----+---------+-------+
| bundle                | varchar(128)     | NO   | MUL |         |       |
| deleted               | tinyint(4)       | NO   | PRI | 0       |       |
| entity_id             | int(10) unsigned | NO   | PRI | NULL    |       |
| revision_id           | int(10) unsigned | NO   | PRI | NULL    |       |
| langcode              | varchar(32)      | NO   | PRI |         |       |
| delta                 | int(10) unsigned | NO   | PRI | NULL    |       |
| field_p_frontip_value | longtext         | NO   |     | NULL    |       |
+-----------------------+------------------+------+-----+---------+-------+


From Berdir's comment



I was trying to set the value of the field 'field_p_frontip' in form_alter as follows , but both didnt worked .

$form['field_p_frontip']["en"][0]['#default_value']['value'] ='192.168.1.100'; $form['field_p_frontip']['#default_value'] = '192.168.1.100';
To update the value of a field for a node, you need to.


Load it
Modify it
Save it


In code it looks like this:

$node = \Drupal\node\Entity\Node::load($nid);
if ($node) {
  $node-&gt;field_p_frontip = '192.168.1.100';
  $node-&gt;save();
}


How you set the value of the field, depends on the field itself. Most fields are simple, and can be set with a scalar value. If field has multiple values or stores more complex data (like the address field), you need to account for this complexity. Usually this is done with arrays.