Code snippet that can be used to change field text format programmatically in Drupal 8.
Example field in node:
$node = \Drupal::entityTypeManager()->getStorage('node')->load($nid);
$node->body->value = 'body';
$node->body->format = 'full_html';
$node->save();
Example field in form:
$form['description']['widget'][0]['#format'] = "basic_html";
Comments
How to set format of a multi value text field in Drupal 8
try this:foreach ($Links…
try this:
use this link to solve your problem https://drupal.stackexchange.com/questions/199044/how-to-set-value-for-multivalue-field-in-drupal-8-programmatically