0

I am trying to get data from a submitted form - as far as I can tell, data is being passed correctly, but I want to look at and manipulate it.

I'm trying to print_r() it with no success - because it happens after form submission and it isn't on the previous page.

This is my submit function so far:

function multi_reg_pagecreate_submit($form, &$form_state) {

$form_state['values']['multi_reg_checkbox'];

}

The checkboxes are generated on the page /multiple-registration, but I have no way of checking my variables once this page is submitted.

Any help would be appreciated

1

The devel module will help a lot. It provides a dpm() function which is similar to print_r() but provides you with a nested array of data to look through in Drupal's messages area.

You're correct in that $form_state['values'] holds the user input, but since the submit handler will return back to the previous page automatically, you're better off doing something like this in your _validate() handler (or throwing a dpm() in your submit handler if you don't mind that running). This will let you debug things quickly and then submit when you're ready for it:

<?php
function my_form($form, &$form_state) {
  // Build out the $form.
}

function my_form_validate(&$form, &$form_state) {
  dpm($form_state['values');
  form_error($form, "Debugging the form.");
}

function my_form_submit(&$form, &$form_state) {
  // Perform your submit functionality here.
}
1

Check your variables by printing them with drupal_set_message().

function multi_reg_pagecreate_submit($form, &$form_state) {
  drupal_set_message('<pre>' . print_r($form_state['values'], true) . '</pre>');
}

Alternatively, you can use debug()

debug($form_state['values'], 'Debugging the form', TRUE);
0

I'm not sure of this, and I'm not a FAPI expert by any stretch but something like:

$form_state['input'] might be useful.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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