0

My form is outputting but has no form tags and is therefore not submitting. I have tried the following:-

In the module... 'page callback' => "drupal_get_form",

function pd_cd_form(){...

From within the callback function... drupal_get_form(pd_cd_form); }

function pd_cd_form(){...

Is there something wrong with the naming of my functions? I cannot understand how the form is being produced but with no tags.

1
  • Is it possible that you have some theme function or template that renders only subitems from the form array?
    – user20301
    Commented Sep 26, 2014 at 7:36

1 Answer 1

1

This could be a number of things. The way drupal produces a form usually starts with the menu system. You would declare the form in something like:

function your_module_menu() {
  $items['your/path'] = array(
    'title' => 'Your Title',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('your_module_formname_form'),
    'type' => MENU_NORMAL_ITEM,
  );
  return $items;
}

Then you create the actual form (which from what it sounds like seems to work), inside your function:

function your_module_formname_form($form) {
  $form['whatever'] = array();
  return system_settings_form($form);
}

and now when you go to your/path, you should see the form you created with a submit button and a default submit handler.

Things to check include whether your form array is properly structured, whether you are trying to override any of the submit mechanism and whether the chain from the menu to the form is uninterrupted and uses the attributes you meant to use.

1
  • 1
    Thanks! As soon as I started to pass in the name of the form in page arguments... eg. 'page arguments' => array('your_module_formname_form'), ..the form tags appeared!
    – daktau
    Commented Sep 26, 2014 at 11:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.