Maybe I Don't Want that in my Form

21 Oct in drupal, module, snippet, theme
Sometimes... most of the times... I don't want the "split summary at cursor" option on the sites I develop. There are any number of reasons I don't want it. Most of the times, it just isn't relevant and others... I just don't want the users asking a milion quesitons.


And inevetibally, there is more stuff I don't want in my forms, want differently, or want moved.


My solution has been that on all the sites I develop I have a custom module. In this modules is one of my most used hooks... form alter. I have it all set up and commended out some of the lines but leave them in for quick reference...


I'll show it to you, then explain a little more....My module name is theme_thingee, and here's how I have it set up.

function thingee_theme_form_alter(&$form, &$form_state, $form_id) {
//print ('<pre>');
//print_r($form);
//print ('</pre>');
//dsm($form_id);
//dsm($form);

unset($form['body_field']['teaser_include']);
$form['body_field']['body']['#rows'] = 5;

  switch ($form_id) {
  // Views Exposed Filters
case 'views_exposed_form':
    $form['submit']['#value'] = t('Search'); // default is 'apply'
    break;

// Form Comment
case 'comment_form':
  drupal_set_title('Post Your Comment');
  break;
}
}


  • The first three lines give me a nice printout in my source... good when I want to see what is happening as a non-logged in user.
  • The next, when you have devel installed. A quick message at the top that prints the form ID is very nice and quick.
  • And dsm on $form with devel is fast and easy with the Krumo window.
  • Next here is my unset of the "split summary at cursor".
  • Followed by changing the number of rows on the body field.
  • The Switch - here is where I use the form ID to make specific changes for specific forms. each case is a different form ID. It allows me fine grain control all in one place.
I like it and it works for me... how bout you?

Comments

Thanks!

It's fun, powerful, and useful,besides,it makes people happy and also I want to see what is happening as a non-logged in user.

One summer afternoon, Former

One summer afternoon, Former President Bill Clinton and his wife Hillary were vacationing in their home state of Arkansas. After a long road trip, they stopped at a service station to fill up their car with gas.A blind man, with a seeing eye dog at his side, walks into his local grocery store. He walks to the middle of the store, picks up the dog by the tail, and starts swinging the dog around in circles over his head.An ambitious young blonde woman, in need of money, decided to hire herself out as a handyman-type. She began, door to door, canvassing a wealthy neighborhood for work. She went to the front door of the first house and asked the owner if he had any jobs for her to do.

Post new comment