Still on Drupal 7? Security support for Drupal 7 ended on 5 January 2025. Please visit our Drupal 7 End of Life resources page to review all of your options.
For some components and configurators I plan to introduce in the future, I want to be able to use static methods in $element['#pre_render']
.
Unfortunately this is not possible natively: drupal_render()
calls function_exists()
, which only allows procedural functions.
Let's introduce a trick for this:
$element['#pre_render'][] = '_renderkit_generic_pre_render';
$element['#renderkit_pre_render'][] = ['MyClass', 'myMethod'];
Comments
Comment #3
donquixote CreditAttribution: donquixote commentedComment #4
donquixote CreditAttribution: donquixote commented