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.
By manniL on
I want to add a form to an article in case a specific token is present. I replaced other tokens with strings successfully, but couldn't manage to insert an entire form. Is this even possible? Else, how to get the desired result?
function my_plugin_tokens($type, $tokens, array $data = array(), array $options = array())
{
$replacements = array();
if ($type == 'form') {
return drupal_render(drupal_get_form('my_plugin_register_form'));
}
}
I'm using the Token and Token_Filter module.
Comments
If it could be done, that is
If it could be done, that is how you would do it. So if that's not working, it probably can't be done.
It does work.. Just a typo
It does work.. Just a typo :facepalm:
I tried
instead of return, but then the form is printed on the top. Return does give me the form text, but without the form itself..
EDIT: Changed text format and it worked!
Good to hear!
Good to hear!