form

form

Drupal 7 Expanded Menu Control On Nodes

I recently noticed a strange little issue with Drupal 7 that seemed like either an oversight or a decision I don't agree with. Essentially, when a node is created with a menu item in place the extended flag on the menu will not be set, but the control is also not available on the menu admin page. This means that when you are trying to print out a hierarchical menu structure you need to create the page, go into the menu admin area, access the menu, click on edit to access the menu item and change the setting there.

Drupal 6 Form Elements Example Module

During my work developing Drupal sites I am quite often asked if I can provide a example of form elements for designers. This is so that they can test their designs with all possible form elements that might appear in a Drupal install and make sure that the theme we create will be robust and future proof. I often find myself forgetting how to create, say, a multi select element and needed a sort of cheat sheet that I could look form elements up on.

PHP Question: Post Variables

Question

Take the following HTML form.

<form id="form" name="form" method="post">
<input type="text" name="number" value="0" />
<input type="submit" />
</form>

What is the output of the following PHP code after the above form has been submitted, and why?

if ($_POST['number'] === 0) {
	echo 'number is zero';
} else {
	echo 'number is not zero';
}

PHP Question: Form Variables

Question

Given the following form:

<form method="post" action="index.php">
<input type="input" value="" name="text" />
<input type="submit" value="Submit" />
</form>

How would you get hold of the value of the input box after the form is submitted?

Overriding Drupal 6 Automatic Select Element Validation

Whilst creating a large and complex form in Drupal 6 recently I hit upon a problem that took me a couple of hours to solve so I am posting the solution here in case anyone else gets similarly stuck. I am also writing this down so that I can remember the strategy in case I have to do the same thing again.

Change Views Exposed Filter Form Select Element To A List Of Checkboxes

Whilst creating a view for a Drupal site the other day I created an exposed form but rather than the usual select boxes that get displayed I needed them to be a list of check boxes. Whilst searching about on Google I eventually found this article, which kindly provides a function that will do this. Here is the function in full.