0
votes

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
Even though Drupal will allow to do that but that will not be a best practice. Instead of that - I recommend that you make use of WEBFORM module. Once you create the webform then it will get that form in the form of block and then you may position that block anywhere onto the page. - Pralhad Narsinh Sonar

1 Answers

0
votes

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;