- Issue created by @sgarsivaz
- ๐ฎ๐ทIran amir jamshidi
hi. I use Drupal 10.2.3 , calendar_systems Version: 4.0.2 and webform 6.2.2 but get this error in webform add element
TypeError: function_exists(): Argument #1 ($function) must be of type string, array given in function_exists() (line 178 of /modules/contrib/calendar_systems/src/Element/CalendarSystemsDateTime.php).
- ๐ณ๐ดNorway naeim
Hi everyone,
I encountered the same error with Drupal 10.2.3, calendar_systems 4.0.2, and Webform 6.2.2:
TypeError: function_exists(): Argument #1 ($function) must be of type string, array given in function_exists() (line 178 of /modules/contrib/calendar_systems/src/Element/CalendarSystemsDateTime.php).
To fix this, I modified the code to check if the callback is a string before calling `function_exists()`. Hereโs the relevant snippet I used:
if (is_string($callback) && function_exists($callback)) { $callback($element, $form_state, $date); }
This prevents passing an array (or other non-string types) to function_exists(), which causes the TypeError.
I applied this check in both #date_date_callbacks and #date_time_callbacks loops. After this change, the error stopped occurring and the webform element addition works properly.
I believe this is a safer and cleaner fix than assuming the callback is an array or accessing $callback[1].