Problem/Motivation
When weight fields are updated via a view using a WeightSelector field, the entity changed date is updated, but no new revision is created. Previous revision user is retained regardless of who made the change via the view.
It would be nice to have the option to create a new revision to track such changes.
Steps to reproduce
Update weight field(s) via a view using WeightSelector. Note that affected entities show as recently updated, but no new revisions are created, and there is no indication of who made the change.
Proposed resolution
1) Add an option to the WeightSelector field to allow creation of a new revision. A default value of FALSE avoids changing current functionality.
2) If the option is selected, create a new revision when saving the affected entity.
Update WeightSelector::viewsFormSubmit()
with something along the lines of:
...
$entity->set($field_name, $row['weight']);
if ($this->options['new_revision']) {
$entity->setNewRevision(TRUE);
$entity->revision_log = 'Updated ' . $entity->get($field_name)->getFieldDefinition()->getLabel();
$entity->setRevisionCreationTime(\Drupal::time()->getCurrentTime());
$entity->setRevisionUserId(\Drupal::currentUser()->id());
}
$entity->save();
...
Remaining tasks
- Write a patch
- Review
- Commit
User interface changes
Add 'Create new revision' option for the WeightSelector view field.