How to use drupal_get_form outside of a menu

I am trying to use the drupal_get_form funtion outside of a menu and am not having any luck finding examples of how this is done.

An overview of what I am trying to achieve is: 1) Pass control from a script using an href html tag passing to another script that will then read what has been passed to the new script and build a form based on the action that has been passed in. I am using the drupal_get_form function just as you would any php function. 2) I am also getting a message that says drupal_get_form is an unknown function.

This script is the initial calling script that contains an html href link to the called processing script.

function view_payment_methods() {   try {$result = db_select('tls_connect_cashier_payment_methods', 'q')     ->fields('q', array('id', 'payment_method', 'payment_desc', 'logically_deleted', 'system_or_user'))     ->orderBy('payment_desc')     ->execute();   } catch(Exception $e) {     watchdog_exception(       'view_payment_methods',       $e,       'Select from tls_connect_cashier_payment_methods has failed.',       null,       'Alert'     );      return false;   }   $payment_methods = $result->fetchAll(PDO::FETCH_ASSOC);    $col1_label           = t('Payment Method');   $col2_label           = t('Payment Description');   $col3_label           = t('Disabled');   $col4_label           = t('Created By');   $col5_label           = t('Action');   $edit_label           = '(' . t('Edit') . ')';   $delete_label         = '(' . t('Delete') . ')';    $markup  = "<h1>" . t('Payment Methods') . "</h1>";   $markup .= "<table>";   $line    = "<tr>";   $line   .= "<td>" . $col1_label . "</td>";   $line   .= "<td>" . $col2_label . "</td>";   $line   .= "<td>" . $col3_label . "</td>";   $line   .= "<td>" . $col4_label . "</td>";   $line   .= "<td>" . $col5_label . "</td>";   $line   .= "</tr>";   $markup .= $line;   if (isset($payment_methods[0])) {     foreach ($payment_methods as $entry) {       $disabled          = '';       $created_by        = '';       $id                = $entry['id'];       $payment_method    = $entry['payment_method'];       $payment_desc      = $entry['payment_desc'];       $logically_deleted = $entry['logically_deleted'];       $system_or_user    = $entry['system_or_user'];       $line              = "<tr>";       $line             .= "<td>" . t($payment_method) . "</td>";       $line             .= "<td>" . t($payment_desc) . "</td>";       if ($disabled == 0) {         $disabled      = 'No';       } else {         $disabled      = 'Yes';       }       $line             .= "<td>" . t($disabled) . "</td>";       if ($system_or_user == 'S') {         $created_by    = 'System';       } else {         $created_by    = 'User';       }       $line             .= "<td>" . t($created_by) . "</td>";       $line             .= "<td><a href = '/TLSConnect3App/sites/all/modules/custom/TLSConnectPackage/cashier/PaymentMethodEditDelete.php?action=edit&id=" . $id . "'>" . $edit_label . "</a>                         <a href = '/TLSConnect3App/sites/all/modules/custom/TLSConnectPackage/cashier/PaymentMethodEditDelete.php?action=delete&id=" . $id . "'>" . $delete_label . "</a></td>";       $markup           .= $line;     }   }   $markup .= "</table>";    return $markup; } 

This script is the called script accessed by way of the html href link for the edit link.

if (isset($_GET['action'])) {   $id = $_GET['id'];   switch ($_GET['action']) {     case 'edit':       $form_id = 'edit_form';       return drupal_get_form($form_id);       break;     case 'delete':       break;   } }  function edit_form($form, &$form_state) {     global $id;     die('chuck');     $form = array(); } 
Sponsored by SupremePR
This article was republished from its original source.
Call Us: 1(800)730-2416

Pixeldust is a 20-year-old web development agency specializing in Drupal and WordPress and working with clients all over the country. With our best in class capabilities, we work with small businesses and fortune 500 companies alike. Give us a call at 1(800)730-2416 and let’s talk about your project.

FREE Drupal SEO Audit

Test your site below to see which issues need to be fixed. We will fix them and optimize your Drupal site 100% for Google and Bing. (Allow 30-60 seconds to gather data.)

Powered by

How to use drupal_get_form outside of a menu

On-Site Drupal SEO Master Setup

We make sure your site is 100% optimized (and stays that way) for the best SEO results.

With Pixeldust On-site (or On-page) SEO we make changes to your site’s structure and performance to make it easier for search engines to see and understand your site’s content. Search engines use algorithms to rank sites by degrees of relevance. Our on-site optimization ensures your site is configured to provide information in a way that meets Google and Bing standards for optimal indexing.

This service includes:

  • Pathauto install and configuration for SEO-friendly URLs.
  • Meta Tags install and configuration with dynamic tokens for meta titles and descriptions for all content types.
  • Install and fix all issues on the SEO checklist module.
  • Install and configure XML sitemap module and submit sitemaps.
  • Install and configure Google Analytics Module.
  • Install and configure Yoast.
  • Install and configure the Advanced Aggregation module to improve performance by minifying and merging CSS and JS.
  • Install and configure Schema.org Metatag.
  • Configure robots.txt.
  • Google Search Console setup snd configuration.
  • Find & Fix H1 tags.
  • Find and fix duplicate/missing meta descriptions.
  • Find and fix duplicate title tags.
  • Improve title, meta tags, and site descriptions.
  • Optimize images for better search engine optimization. Automate where possible.
  • Find and fix the missing alt and title tag for all images. Automate where possible.
  • The project takes 1 week to complete.