Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
There is a wrong created function when you have a entity_reference multivalue field. The set part is correct but the get function only works if there is one entity referenced
public function setCommissions($value) {
if (is_array($value)) {
foreach ($value as $i => $v) {
if ($v instanceof WdAffiliateMlmWrapper) {
$value[$i] = $v->value();
}
}
}
else {
if ($value instanceof WdAffiliateMlmWrapper) {
$value = $value->value();
}
}
$this->set('field_commissions', $value);
return $this;
}
/**
* Retrieves field_commissions
*
* @return CommisionsAffiliateMlmWrapper
*/
public function getCommissions() {
$value = $this->get('field_commissions');
if (!empty($value)) {
$value = new CommisionsAffiliateMlmWrapper($value);
}
return $value;
}
Comments
Comment #2
fox_01 CreditAttribution: fox_01 commentedI modified the function to this which is working
Comment #3
fox_01 CreditAttribution: fox_01 commentedcan this be integrated into a release?
Comment #4
zengenuity CreditAttribution: zengenuity at DrupalTutor / Zengenuity commentedDid you change your cardinality on this field? Did it used to be a single value? If so, you need to clear this function and regenerate. When I test things from scratch, it works fine with multi-valued entityreference fields.
Comment #5
zengenuity CreditAttribution: zengenuity at DrupalTutor / Zengenuity commented