Drupal 8:如何编辑“段落”字段值?

问题描述

我想知道是否可以设置一个段落的值。 在我的模块中,我使用了entity_presave函数,如果我尝试获取Paragraph值,则其工作正常,但是如果我尝试设置或编辑值,则其以某种方式无法工作。

function setParagraph($node)
{
  $paragraph = $node->field_paragraphs->getValue();
  // Loop through the result set.
  foreach ($paragraph as $element) {
    $p = \Drupal\paragraphs\Entity\Paragraph::load($element['target_id']);
    $foo = $p->field_foo>value;
    $bar = $p->field_bar->value;

`$foo and $bar are getting filled with the right values`

but if i want to set a value nothing will work 

    $p->set('field_foo',$bar); //not working
    $p->field_foo = $bar;  //not working
    $p->field_foo->value = $bar; notworking
    //$p->set('field_steamconnect',$steamconnect);
  }
}

解决方法

import tensorflow as tf 

将起作用

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...