2

I am creating content and in fields i want to categorize fields, like a heading and then its related fields.For eg this is html field i m converting into drupal 7.enter image description here

Now how can i get this heading project report information and construction details in creating or viewing content

1

Here is an example of putting heading (fieldset) on a comment form that I found a while back: click here.

Basically you need to do a hook_form_alter().

Start by creating a field set:

fucntion HOOK_form_FORM_ID_alter() {

$form['project_report_information'] = array(
    '#type' => 'fieldset',
    '#title' => t('Project Report Information'),
    '#collapsible' => FALSE,
  );

Next, add your fields to the field set and remove the field outside the fieldset:

$form['project_report_information']['subject'] = $form['your_field'];  //add to field set
unset($form['your_field']);                                            //remove field outside
$form['project_report_information']['your_field']['#weight'] = -10;    //of fieldset

Now repeat this for all fields and fieldsets you want.

Look over the link for a more detailed example of someone doing this. What you want is about half way down the page.

| improve this answer | |
  • I'm not sure if this will apply when viewing the content type but I'd be interested to know if it does. – Mike May 22 '12 at 7:47
0

You can easily use the Field Group module for this!

Fieldgroup will, as the name implies, group fields together. All fieldable entities will have the possibility to add groups to wrap their fields together. Fieldgroup comes with default HTML wrappers like vertical tabs, horizontal tabs, accordions, fieldsets or div wrappers.

You can put your fields into fieldsets, accordions, horizontal tabs, or vertical tabs just by dragging and dropping into created groups. Just give your field grouping the title that you want (Project Reporting Information for example) and then drag and drop the fields into the group.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.