0

I am running a drupal 7 migration into Drupal 8 paragraphs. I am retrieving the source fid, mapping from the file migration, getting the dest file id, getting the source file description, and then creating a new file paragraph that just contains a public_file field.

Problem is that I can't find a way to set the description field of the file? I can create the paragraph with the file fine.

I have tried the following (where field_files is the name of the field in the paragraph)

$file->set('description', $file_title);

.

$file->field_files[0]['description'] = $file_title;

.

$paragraph->set('field_files', $file);
$paragraph->set('field_files_descriptions', $file_title);

I have tried creating a test paragraph through the front end containing a description field and inspected the values, and there isn't anything obvious where I can set the value,

$testparagraph = $paragraph->getFields();
$testfile = $file->getFields();

The description value is only here in the paragraph entity

$testparagraph['field_files']->list[0]->values['description']

I'm at a bit of a loss where I can set this description.

2

The answer was incredibly simple

$paragraph->field_files->description = $file_title;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.