systopia / de.systopia.twingle

CiviCRM Twingle Integration
Other
4 stars 2 forks source link

Error on settings page - broken API parameter structure for activity assignee EntityRef field #61

Closed MarcMichalsky closed 1 year ago

MarcMichalsky commented 1 year ago

This issue may be related to #56.

When opening the Twingle API - Generic Settings page, an error message is displayed:

Screenshot 2023-02-14 at 09-28-15 Twingle API Settings CiviCRM forumZFD

contact_type is an array, but only strings are allowed in $attributes.

Bildschirmfoto vom 2023-02-14 09-07-02

The problem is the twingle_protect_recurring_activity_assignee selection field, which seems to pass an invalid array structure to $this->addEntityRef().

https://github.com/systopia/de.systopia.twingle/blob/1b684624016a72f251f6b621b94799f759b2485e/CRM/Twingle/Form/Settings.php#L92-L99

According to the documentation, the array passed to $this->addEntityRef() must be structured as follows:

// Use the 'option_value' entity for most "option" lists, e.g. event types, activity types, gender, individual_prefix, custom field options, etc.
$this->addEntityRef('field_5', ts('Activity Type'), [
  'entity' => 'option_value',
  'api' => [
    'params' => ['option_group_id' => 'activity_type'],
  ],
  'select' => ['minimumInputLength' => 0],
]);

If the array is structured correctly, the problem is solved:

Bildschirmfoto vom 2023-02-14 10-31-46

jensschuppe commented 1 year ago

Thanks @MarcMichalsky!