Problem/Motivation
I would like to add remove Referenced Entities to and from appropriate entity fields which can contain more than one reference.
Steps to reproduce
Proposed resolution
Have two Reaction rules one to add and the other to remove. They both take the entity type id . field name as one parameter and the other is the entity to add or remove. The Load entity by id functionality is one way of determining the entity.
Remaining tasks
Add tests.
User interface changes
None
API changes
None
Data model changes
None
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | rules-data-list-item-remove-3198011-4.patch | 1.35 KB | Tramb |
Issue fork rules-3198011
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
tr commentedComment #3
tr commentedYour patch had six coding standards problems - see the test output.
Why can't you use DataListItemAdd for this?
Comment #4
somersoft commentedFor the two new files I have update the code to following coding styles.
I tried to use DataListItemAdd and DataListItemRemove but could not work out what to put in the list box to produce an array from a field for example a list of target_id if the field references multiple other same entities. It may be that those two functions need to change but I do not want to break rules that currently use them.
Please advise if there is away to use DataListItemAdd and DataListItemRemove.
Comment #5
tr commentedSet to needs review to trigger testing
Comment #6
TrambThe patch #3 does not work for me (a user list item field).
I propose a patch for the list item remove functionnality, that can take an array or a FieldItemList now.
But it only works on PHP 8.x due to union types.
It works on my 9.4 Drupal.
Comment #7
somersoft commentedRerolled for PHP 8.1
Comment #8
somersoft commentedThe Add functionality was not working and it has been updated in the fork.
Comment #9
somersoft commentedRemoved patch as it is now out of date.