Search code examples
formsdrupaldrupal-7drupal-modulesform-control

Add a Canvas Form Control in Drupal Custom Module


Im currently developing a module and I have this code in html:

<canvas id="cnv" name="cnv" width="500" height="100"></canvas>

I want it to add in my page using form controls but when I scan through Form API Reference , there's no canvas form control available. How to make it possible in Drupal? Any idea?


Solution

  • Geez, what have they dont to that page? It use to be easy to read.

    Anyway, you can use the markup type, which is the default so no need for '#type'.
    eg.

    $form['mycanvas'] = array(
      '#markup' => '<canvas id="cnv" name="cnv" width="500" height="100"></canvas>',
    );
    

    Though I'm not sure what you are doing with the canvas and if that will affect anything.