[development] Implementing without nodes

Alessandro Feijó patrao at legendas.feijo.info
Wed Dec 19 13:11:30 UTC 2007

What a fantastic reply!! Thanks a lot, Garfield,

I successfully set my form to work!!


----- Original Message ----- 
From: "Larry Garfield" <larry at garfieldtech.com>
To: <development at drupal.org>
Sent: Wednesday, December 19, 2007 12:01 AM
Subject: Re: [development] Implementing without nodes

If you want a form that is detached from the node concept, you just define 
form itself and call it from the menu handler directly.  You can use
hook_forms() for it, but don't have to.  The form itself gets submitted as
normal, and you have complete control over it.

A bare skeleton might look like this:

function example_menu($may_cache) {
  $items = array();

  if ($may_cache) {
    $items[] = array(
      'path' => 'example',
      'callback' => 'drupal_get_form',
      'callback arguments' => array('example_form'),

  return $items;

function example_form() {
  // define your $form here, reading from the DB as needed.

function example_form_validate($form_id, $form_values) {
  // Do stuff with $form_values here and set errors if needed.

function example_form_submit($form_id, $form_values) {
  // Do stuff with $form_values here and call DB queries if needed.

Now going to /example will display the form defined by example_form(), and
when it's submitted it will first be validated by example_form_values() and,
it passes, will get passed to example_form_submit() for whatever saving you
want to do.

For more information, see:

You can, of course, get ridiculously more complicated than that (especially
when you start working with custom theming of forms, which is all sorts of
exciting), but that should get you started.


On Tuesday 18 December 2007, Feijó Legendas wrote:
> I'm trying to figure out how to implement several modules, that do not use
> nodes at all
> I need to set lots of forms, this forms are used to edit, insert or search
> my tables
> I'm having dificulty controling the data flow of my forms.  What hooks I
> use? I try hook_form, but any code I set there isnt executed.
> Every site about hook_form, uses node! Can I do that without nodes?
> Feijó

Larry Garfield AIM: LOLG42
larry at garfieldtech.com ICQ: 6817012

"If nature has made any one thing less susceptible than all others of
exclusive property, it is the action of the thinking power called an idea,
which an individual may exclusively possess as long as he keeps it to
himself; but the moment it is divulged, it forces itself into the possession
of every one, and the receiver cannot dispossess himself of it."  -- Thomas

More information about the development mailing list