Maybe I Don't Want that in my Form
21 Oct
Posted by webthingee
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.
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.
Comments
Thanks!
One summer afternoon, Former
Post new comment