Last updated July 14, 2011. Created by Dublin Drupaller on July 14, 2011.
Log in to edit this page.
Introduction
I created the following snippet recently for a project where the client wanted help text for node TITLE and node BODY fields.
Step 1 of 2
Copy the following snippet into a custom projectname_overrides.module and modify projectname to suit.
If you don't already have a projectname_overrides.module setup for your project. See below for a simple module .info file you can use.
The following uses the node type variable so the help text is dynamic for each content type. You can obviously go further and have custom descriptors for specific content types.
<?php
/**
* Adding help text to node title and body fields
*/
function projectname_overrides_form_alter(&$form, &$form_state, $form_id) {
$form['title']['#description'] = '<p>' . t('Enter a title for the '. $form['type']['#value'] .' item.') . '</p>';
$form['body_field']['body']['#description'] = '<p>' . t('Enter a description for the '. $form['type']['#value'] .' item. This should be at least ten (10) words.') . '</p>';
}
?>Step 2 of 2
Enable the module and refresh the node edit page. You may need to clear cache prior to this.
projectname_overrides.info file
Here's a projectname_overrides.info file you can copy and use if you don't already have a custom projectname_overrides.module set up.
; $Id$
name = Custom Overrides
description = Custom overrides module
core = 6.xNotes
- Tested by Dublin Drupaller July 2011 with drupal 6.x and pressflow
- Please add a child page to this handbook page if you find an improvement or more efficient way of doing this
Comments
D7 port
Hello!
This is what I was looking for D7. can anyone please port this for D7?
Thanks a lot
D7 code needed
Also need this code for D7.
I ♥ Drupal.