Created
August 5, 2014 03:12
-
-
Save xtfer/f2a152be9aa8bcd8b163 to your computer and use it in GitHub Desktop.
Ghost: Calling Form Controllers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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