2017-04-18 133 views
0

我已經在drupal 8字段集合中創建了一個文件上傳,但我沒有收到。如何在drupal 8中保存字段集合無限字段?

請給我建議!我可以做什麼 ?

$node_data = [ 
    'type' => ur_content_type, 
    'title' => 'ur title, 
    'langcode' => $this->languageManager() 
    ->getCurrentLanguage() 
    ->getId(), 
    ]; 
    $node = Node::create($node_data); 
    $node->save(); 
    $file_content = my url of file 
    $directory = 'public://'; 
    $file = file_save_data($file_content, $directory . 
basename($url), FILE_EXISTS_REPLACE); 
    $fc->field_collect_filed_unlimited->setValue($file->id()); 
    $fc->setHostEntity($cv_node); 
    $fc->save(); 
    $Node->save(); 

回答

1

嘗試通過數組數組 $ a = array(); 傳遞該數組中的所有$ file-> id(),然後傳遞該數組$ fc-> field_collect_filed_unlimited-> setValue($ a);

相關問題