hook_form_alter

By Phil Frilling, 16 October, 2013
I recently needed to alter the address fields within the Ubercart 3 billing pane. Unfortunately, due to the way Ubercart 3 builds these form elements, the standard hook_form_alter() hook was not going to work. After a few hours of searching I finally discovered this post: https://drupal.org/node/2063949#comment-7750227 With that information I was able to alter my billing pane's company field into a select list taken from a taxonomy.
By Phil Frilling, 31 May, 2012
Today's project required me to fine tune Drupal's standard book module. Basically, I needed to limit the choices in the 'Book Outline' area to only display books that the user was the author of. Unfortunately, Drupal's default permissions don't allow for this. Either the user can administer all outlines or none, nothing in between.

Form Alter to the Rescue

So I created a custom module with a hook_form_alter() function and started inspecting the $form variable. The book outline form options are keyed with the node id, which I can use to check the author.
By Phil Frilling, 31 January, 2012
Today I needed to create a view the filtered items by a range of prices. The prices for these nodes were stored in a CCK number field. After searching for an easy 'plug and play' method of doing this I quickly began writing my own code to accomplish this task. To summarize, I accomplished this by using the following functions:
  • hook_form_alter()
  • hook_views_query_alter()

Step 1.

Begin by creating your view and adding your CCK number field as an exposed filter. You'll want to be sure that you use the 'is between' operator.