Upload form inside Drupal block

95 views Asked by At

I wish to make an upload form inside a Drupal block (with PHP-code enabled) and I wish the validation / treatment to be on the same block.

All I have found are either PHP specific code (creating a form and redirect to an 'upload.php' page) or Drupal module code (upload.inc with functions to create, submit and validate the form)...

What should I do?

1

There are 1 answers

0
pal4life On

There is the advanced block module that can help you place form inside a block. Could also try the form block module if that works for this situation depending on what the upload is for.

Custom Module: This can also be easily done via custom module. As this answer here recommends

function yourmodule_block_view($delta='')
{
  switch($delta) {
    case 'your_block_name':
      $block['subject'] = null; // Most forms don't have a subject 
      $block['content'] = drupal_get_form('yourmodule_form_function');
      break;
   }
   return $block;
 }

the form array returned by drupal_get_form will be automatically rendered.

yourmodule_form_function is a function (in your module or an existing Drupal module) that returns the form array;