So - in working with creative designers, we've had the need to design some pretty intricate search boxes. In a site I just completed for Jeff at Brightwhite, he used a jQuery text replacement with some slick visuals. The result left me in a bit of a mental pinch! The issue : When I was doing this, I was getting an error from the Drupal system Validation error, please try again. If this error persists, please contact the site administrator. Drupal needs to know that a form it's processing has been submitted by the system, therefore with a search request, comes a validation token.
My solution (and I borrowed much of it from "The Agaric Way") was to implement a module which hooks the _form_alter for the Search form and Search themed forms and simply tell it not to bother validating the token. Simple, eh? That's only part of it. Part 1 was to create my search template file. I created a file called block-search.tpl.php and drop it in my theme folder.
There are a couple of important things to note. First: the form action. That'll be the same for all of your search forms. The first two inputs (text and button) are the text field and the button.
It's important to note the names of these controls. That's it. The ID, Class, Values should be changed to match your template code. The really important ones to note are the last two hidden fields. You can simply paste these two in as well as the line of code for Form Action.
The substitutions will be to the text and button fields. The next step is to create a little module. Admittedly, I am pretty new to module development, so I hit up Drupal Site for some tips on creating the module. In the end, I've created the SearchFilter module. The main focus of the module is to set the tokens off: $form['#token'] = FALSE; unset($form['#token']);
With this handy little module in place and a custom search form, you're off to the races! Questions, comments or need a hand? Drop us a line.
