Hi,
We've used CCK to setup a custom content type, and we'd like to add help text to the title and body fields, as we've done for all the other fields. For example, we're tracking legislation, and we added a "Sponsors" field, and we could put the help text "Legislators who sponsored this bill." When writers are adding new legislation nodes, they will see that help text next to that field.
For the "Title" and "Body" fields, we have specific guidelines for what they should put in those fields, and we'd like to put help text next to them (as we've done with all the other fields) in order to remind writers of those guidelines.
But, apparently because they are "default" fields, it won't let me add help text on the "Manage Fields" page that CCK gives you. There's no "configure" link, and the appearance of the text suggests that you are not allowed to make changes to these "default" fields, as you can see from this screenshot:
http://content.screencast.com/users/jbeall/folders/Default/media/a96caf5...
Comments
How to Fake it
Here's what I did to fake it. In this case I was working with a content type called "profile". The help text I wanted to add was "This site is moderated. Profane and sexually explicit content will be removed."
Step 1. In a custom module:
Step 2. In the CSS sheet:
"#edit-body-wrapper" was targeted because (in the Acquia Marina theme, anyway), there was a margin defined below the wrapper. Your theme may not have that.
"#node-form .body-field-wrapper .help" was the class I made up for my mock help text (see step 1). I simply gave it the same properties as ".description", a class that already existed in my theme.
-------------------------------------------
Interactive Worlds and Immersive Obsessions
http://www.asifproductions.com
Hi, I have got that running
Hi,
I have got that running with your example for the body field.
could you provide another example for e.g. the title or language selection field?
haven't found a solution to change that one.
best regards,
Sandroz
print_r is your friend
Once you start applying print_r() to things in Drupal, you'll begin figuring it all out. Everything is an array or an object with a meaningful structure. Here's a print_r dump routine that prints the structure of the profile form in a textarea:
If you examine that dump you will see where I got $form['body_field']['body']. It's just a set of nested arrays. So the title is
$form['title']['#title']Obviously you don't want this textarea displaying on a production site. But if you have no other option, you can always hide it. Here's one way: replace the IF line with this...
...and replace "111.222.333.444" with your own IP address. This way you will be the only person who sees the print_r dump.
-------------------------------------------
Interactive Worlds and Immersive Obsessions
http://www.asifproductions.com
dpm is an even better friend ;-)
The Devel module's
dpm()function is designed to do this very thing, more simply and powerfully:It even handles the problem of showing debug information to the public by defining a permission required to see the message. Enjoy!
yes, but...
yes dpm() is a great thing, but personally I wouldn't spend the time to download and install a module (especially a big one like Devel) when I just want to dump an object real quick. Besides, teach a man to fish, and all that. ;-)
-------------------------------------------
Interactive Worlds and Immersive Obsessions
http://www.asifproductions.com
Should be #description
Help for CCK fields is simply $form['fieldname']['#description'], and most themes are probably looking for the resulting .description div. This works very well for me with the Rubik theme for node title and body, presenting the help as mouseover popups the same as other help fields:
Next step is to make it node-type aware via an admin interface that hooks into the content-type basic settings form, adding body and title help fields.
Is anyone aware of any module already doing this? Don't want to reinvent the wheel...
Node title help text
This module can be used to add help text to node title
https://www.drupal.org/project/node_title_help_text