I successfully managed to save a flag programmatically in Drupal 8 thanks to this help but I cannot manage to save data into a custom field I added to the flag entity.
The following code saves the flag but the field stay empty.
$entity = \Drupal::entityTypeManager()->getStorage('node')->load($entity_id); $flag_id = 'bookmark'; $flag_service = \Drupal::service('flag'); $flag = $flag_service->getFlagById($flag_id); /* Here is where I'm trying to set my custom field value */ $flag->set('field_my_custom_field', $link_name); $flag_service->flag($flag, $entity);
I cannot find any info into the documentation. Any help will be much appreciated.