Problem/Motivation
When working with an multi-valued entity reference field, I noticed that only the first value was inherited. I believe the FieldStorageDefinition is missing setCardinality as per this blog post.
Steps to reproduce
- Configure a multivalued field inheritance (in my case a taxonomy term on a recurring event)
- Add multiple values to the field
- Observe only the first value is passed to the destination field.
Proposed resolution
Add setCardinality.
Issue fork field_inheritance-3316144
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 #3
froboyComment #4
erikaagp commentedthe way how setCardinality was implemented, works for me.
Comment #5
froboy@erikaagp thanks for your time! As this is a small but nontrivial change, could you please provide more detailed feedback or testing steps you used?
Thanks again, and welcome!
Comment #6
owenbush commentedThis change looks good and makes sense to me.
One thing I wonder is for inherited fields that append or prepend, this may be problematic. If the cardinality of the source field is 3, for example, and we set the cardinality of the inherited field to 3, then what happens with values appended/prepended?
There are a couple of approaches we could take:
1. Always just make them unlimited, to handle any combination of source+destination field cardinalities
2. Set to unlimited if source field or destination field are unlimited, otherwise source field cardinality + destination field cardinality
Given that this has probably arisen from a use-case of yours, what approach do you think makes most sense to handle the possibility of appending/prepending values from the destination entity too?
Comment #7
owenbush commentedI've gone ahead and made some changes to better determine what the cardinality should be.
Inherited fields will just use the source field cardinality
Fallback fields will use the larger of the source field and destination field cardinalities, unless one of them is unlimited, in which case it will be unlimited.
Appended/Prepended fields will use the source cardinality + the destination field cardinality - unless one of them is unlimited, in which case it will be unlimited.
Comment #8
plopescMoving to 3.x
Comment #11
plopescMR merged!