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

Jaypan’s picture

If it could be done, that is how you would do it. So if that's not working, it probably can't be done.

manniL’s picture

It does work.. Just a typo :facepalm:

I tried

print

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!

Jaypan’s picture

Good to hear!