public function submitForm(array &
$form, FormStateInterface
$form_state) { $response =
new AjaxResponse();
// Convert any uploaded files from the FID values to data-entity-uuid
// attributes and set data-entity-type to 'file'.
$fid =
$form_state->
getValue(['fid', 0
]);
if (!
empty($fid)) { /** @var \Drupal\file\FileInterface $file */
$file =
$this->fileStorage->
load($fid);
$file_url =
$file->
createFileUrl();
$form_state->
setValue(['attributes', 'src'
],
$file_url);
$form_state->
setValue(['attributes', 'data-entity-uuid'
],
$file->
uuid());
$form_state->
setValue(['attributes', 'data-entity-type'
], 'file'
);
} // When the alt attribute is set to two double quotes, transform it to the
// empty string: two double quotes signify "empty alt attribute". See above.
if (trim($form_state->
getValue(['attributes', 'alt'
])) === '""'
) { $form_state->
setValue(['attributes', 'alt'
], ''
);
}