User login

Display everything about a form in Drupal 5

To display everything about every form, Agaric uses this in a form_alter hook implementation:

drupal_set_message('<p>Form ID: ' . $form_id . '</p><pre>' . print_r($form, TRUE) . '</pre>');

In fact, we wrap it in our own function, which we have in our development module, agaric:

function agaric_f($form_id, $form) {
  drupal_set_message('<p>Form ID: ' . $form_id . '</p><pre>' . print_r($form, TRUE) . '</pre>');
}

This is a more... complete... overwhelming... version of the line Agaric suggested for displaying the form ID of all forms.

Also check out the Devel module, which has a setting to display form element IDs and weights. This might be a good in between, but Agaric asks "why do things halfway?"

Once we at Agaric are a little more sure that we know what we're doing, we will see if other developers are interested in having these little development-help functions put in a module like devel.

We assume a good Integrated Development Environment (IDE) would make this unnecessary, but some of us at Agaric and a lot of other developers too don't have an IDE they like.

To display everything about every form, Agaric uses this in a form_alter hook implementation:

drupal_set_message('<p>Form ID: ' . $form_id . '</p><pre>' . print_r($form, TRUE) . '</pre>');

In fact, we wrap it in our own function, which we have in our development module, agaric:

function agaric_f($form_id, $form) {
  drupal_set_message('<p>Form ID: ' . $form_id . '</p><pre>' . print_r($form, TRUE) . '</pre>');
}

This is a more... complete... overwhelming... version of the line Agaric suggested for displaying the form ID of all forms.

Also check out the Devel module, which has a setting to display form element IDs and weights. This might be a good in between, but Agaric asks "why do things halfway?"

Once we at Agaric are a little more sure that we know what we're doing, we will see if other developers are interested in having these little development-help functions put in a module like devel.

We assume a good Integrated Development Environment (IDE) would make this unnecessary, but some of us at Agaric and a lot of other developers too don't have an IDE they like.

Comments

Post new comment

The content of this field is kept private and will not be shown publicly.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • You can use Markdown syntax to format and style the text. Also see Markdown Extra for tables, footnotes, and more.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <img> <blockquote> <small> <h2> <h3> <h4> <h5> <h6> <sub> <sup> <p> <br> <strike> <table> <tr> <td> <thead> <th> <tbody> <tt> <output>
  • Lines and paragraphs break automatically.

More information about formatting options

By submitting this form, you accept the Mollom privacy policy.