Skip to content

Instantly share code, notes, and snippets.

@killua99
Last active December 19, 2015 04:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save killua99/5901069 to your computer and use it in GitHub Desktop.
Save killua99/5901069 to your computer and use it in GitHub Desktop.
two form in one page drupal
<?php
/**
* Implements hook_menu().
*/
function custom_two_form_menu() {
$items = array();
$items['custom'] = array(
'title' => 'Custom',
'description' => 'Two forms one page',
'page callback' => 'custom_two_form',
'access arguments' => array('access content'),
);
return $items;
}
/**
* View form.
*/
function custom_two_form() {
$output = '';
$form_one = drupal_get_form('first_form');
$output .= drupal_render($form_one);
$form_two = drupal_get_form('second_form');
$output .= drupal_render($form_two);
return $output;
}
/**
* First form.
*/
function first_form($form, &$form_state) {
$form = array();
...
return $form;
}
/**
* Second form.
*/
function second_form($form, &$form_state) {
$form = array();
...
return $form;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment