I have an issue with a form I built in a custom module using drupal_get_form() on a menu callback.

My form callback function is _foo_form($form, $form_state) and my submit function _foo_form_submit($form, $form_state).

When I submit the form, $form_state['values'] contains the value in the form callback, but in the submission handler $form_state['values'] is empty.

Here is my module code:

function configurator_menu() {
  $items = array();
  $items['node/%/configurator/items'] = array(
    'title' => 'Steps & items',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('_configurator_node_edit_item', 'list', 1, ''),
    'access arguments' => array('administrer configurator'),

function _configurator_node_edit_item($form_state, $op, $nid, $iid) {
  $form = array();
  $form['nid'] = array(
    '#type' => 'hidden',
    '#value' => $nid
  $form['title'] = array(
    '#title' => 'Step label',
    '#type' => 'textfield',
    '#value' => '',
    '#size' => 30
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => 'Save',

  return $form;

function _configurator_node_edit_item_submit($form, $form_state) {
  dpm($form_state['values']); // devel function to print variable in drupal messages
  // returns an empty array

Do you have any idea?

  • 2
    Add your form's code (and submit's too) to your question, would be easier to investigate. Jul 1, 2011 at 12:10
  • I just copied a few pieces of my code and forgot the submit button. It don't have any other field that the one listed above. I get to the _submit handler, the function returns my dpm() test. The $form_state['values'] should contain the results but it remains empty... Jul 1, 2011 at 13:20
  • Would it be easier to create a new callback function and include drupal_get_form() within that function? Seems like passing values would be simpler.
    – Citricguy
    Jul 2, 2011 at 2:55
  • Actually I started by having a regular menu callback that was including a drupal_get_form(). When i found i can pass several values from the drupal_get_form to the callback i choose to simplify my code. I've built many forms with Drupal API and this is the first time I cannot get it working. I'll try my module in a different drupal install, and if it still doesn't work i guess i'll rewrite it from scratch... Jul 2, 2011 at 8:16
  • How would you pass arguments to your form callback ? I need to pass some arguments from the form to the submit and don't want to do it using the URL. I've been reading Forms API documentation as well as drupal_get_form code and documentation. $args = func_get_args(); is used in drupal_get_form() to pass arguments from a function to another. Nevertheless, i'm not really sure that Drupal doesn't rewrite or reset some of my variables... Jul 2, 2011 at 9:38

1 Answer 1


Change property '#value' to '#default_value'.


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.