Skip to content

Instantly share code, notes, and snippets.

@xtfer
Created August 5, 2014 03:12
Show Gist options
  • Save xtfer/f2a152be9aa8bcd8b163 to your computer and use it in GitHub Desktop.
Save xtfer/f2a152be9aa8bcd8b163 to your computer and use it in GitHub Desktop.
Ghost: Calling Form Controllers
<?php
/**
* How to call a form within a function.
*/
function ghost_examples_form_controller() {
$form = drupal_get_form('ghost_form', 'Drupal\ghost_examples\Form\ExampleForm');
$output = drupal_render($form);
return $output;
}
/**
* Implements hook_menu().
*
* Calling your form from a menu callback.
*/
function ghost_examples_menu() {
$menu = array();
$menu['my/page/callback'] = array(
// Your page callback should always be the same.
'page callback' => 'ghost_form',
// Your page arguments should start with your Controller, and the method
// to call.
'page arguments' => array(
'Drupal\ghost_examples\Form\ExampleForm',
),
);
return $menu;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment