On the manage fields screen of my content type there are a number of system supplied fields that are greyed out (Groups, Title, Body, etc.). I cannot move these to within a field group by dragging. Is there any way to get them into a field group?

Comments

brainski’s picture

I have the same issue:
- body
- title

are not movable to a group.

yched’s picture

That's because Body and Title are not CCK fields. Fieldgroup won't support changing locations of non CCK form elements. The modules that define those fields need to be able to find those form elements where they put it, changing this under them would open up very interesting ways of breaking lots of different things.

hass’s picture

Same issue here... Are we not able to make this a special case grouping that is only visual? Not having the ability to group make CCK nodes looking strange and unordered and not user friendly. I would also be more happy if I'm able to completely remove the two standard fields and create my own.

WorldFallz’s picture

As indicated in the instructions on the node edit form, removing the 'body' label should remove the field. You cant remove the title field, but you can use http://drupal.org/project/auto_nodetitle to hide it. Then use cck fields for everything and group as you wish.

===
"Give a man a fish and you feed him for a day. Teach a man to fish and you feed him for a lifetime." - Lao Tzu
"God helps those who help themselves." - Ben Franklin
"Search is your best friend." - Worldfallz

capellic’s picture

I'd be wary of this route -- it's hackish. First, you have the title data in two different fields. Then you have a blank body but another CCK field pretending to the body. I see complications down the line with regard Drupal's auto generated Teaser string as well as search indexing.

quixote’s picture

After much try/fail, I was able to get this working. I moved my body field into a CCK field group with a form override. Here's the code:

// move the body field into the group of my choice
array_push($form['group_whatever'], $form['body_filter']);

$form['body_filter'] = array(); // empty out the body field's old array

// Output the form
print drupal_render($form);

The way it works, is it tacks the body field onto the array of your fieldgroup, then it wipes out the value of the old body field (so it does not display twice).

My setup uses some custom modules to let me override forms with template files. To do this, put this code inside template.php:

function phptemplate_node_form($form) {

// enable custom template for My Content Type entry form
	if ($form['form_id']['#value'] == 'your_node_form_id') {
		return _phptemplate_callback('mytype_edit', array('form' => $form));
	}


}

Then create a file called mytype_edit.tpl.php, where mytype is whatever your content type is (example: story-edit.tpl.php). That's where you should place your node form overrides.

capellic’s picture

Another solution, which I prefer because I already have a hook_form_alter module defined this:

function hook_form_alter_form_alter(&$form, $form_state, $form_id){
  if ($form_id = "YOUR_FORM_ID") {
    array_push($form['YOUR_GROUP_ID'], $form['title']);
    array_push($form['YOUR_GROUP_ID'], $form['body_field']);
    unset($form['body_field'], $form['title']);
  }
} 
capellic’s picture

Hmm... it seems that moving title to the field group causes the form to save without a title. It gets past validation, but then the string is empty on View and Edit.

capellic’s picture

OK, I figured out what was going wrong.

While it seems to be OK with pushing body_field onto the form, doing so with the title field doesn't work. I looked at the $form_state on save and saw that the title value was at the array key [0] instead of [title]. When you pus a value onto an array you are not supplying an explicit key value and so you get an auto-incremented number -- much like a unique key in a database.

For title, we need to set the array key explicitly. Here is the code block with the correction:

function hook_form_alter_form_alter(&$form, $form_state, $form_id){
  if ($form_id = "YOUR_FORM_ID") {
    $form['YOUR_GROUP_ID']['title'] = $form['title'];
    array_push($form['YOUR_GROUP_ID'], $form['body_field']);
    unset($form['body_field'], $form['title']);
  }
}
good_man’s picture

you are duplicating form_alter in method name. You should call it mymodulename_form_alter

jduff’s picture

The best way to go about this is to use the '#after_build' hash.

Example:

hook_form_alter(&$form, $form_state, $form_id) {
   
 // a switch structure can be used if you have a lot of forms that need altering
 if($form_id ==  'contenttype_node_form') {    // node form for content type
    $form['#after_build'][] = 'form_after_build';  // form_after_build being a custom callback method
  }
}

function form_after_build($form, &$form_state) {
  $form['cck_field_group']['title'] = $form['title'];
  unset($form['title']);

  // this can be done with body etc...
  
  return $form;
}
radiobuzzer’s picture

Hi, your solution worked. I just would also be interested to do this for the node view mode, and not only the view edit form.

HerrSerker’s picture

Go here:
admin/content/node-type//display

Then check the 'hidden' checkbox for your group_field

ryan_courtnage’s picture

Agreed ++

gleich’s picture

Thanks, it's simple and it worked for me.

Such things should be collected to some sort of Drupal FAQ named "How to fight all these little annoying restrictions" :)
Have encountered too much of them already...

chananiel’s picture

Jduff

your solution works perfectly!!

mwaqas47’s picture

You can do this by editing content type below Multistep Form setting here is extra fields setting here u can set which field goes to which group. i.e title, body, taxonomy etc

radiobuzzer’s picture

Sorry, your comment is a bit unclear. Could you explain what you mean "below Multistep Form setting"? Where is this Multistep form setting?

johnhanley’s picture

The previous poster is referring to the Multistep module. As the name suggests it provides the means to split up a CCK form into multi-page steps, but a residual benefit of the module is that it also allows the title and body to be added to a field group.

sansui’s picture

I tried out the multi step module, does seem to enable this nicely. I would prefer to use cck fieldgroup tabs myself instead of the "wizard" approach, so if nothing else, perhaps I can dig through multistep to see how they're moving these non-CCK fields into the appropriate groups.

Cablestein’s picture

I just tried the Multistep module... it does give you some fashion of 'grouping' control, but I don't think it's what most people are looking for. Just to be clear it doesn't relate with Fieldgroups (the CCK module) at all. Grouping form components with Multistep gives you each group acting as a step in the form. Each step is it's own 'page', requiring a browser refresh, only showing the components for the particular group. You still don't have a class connection between form components to style a group visually on a single page... which is what I think people want ala CCK Fieldgroups.

LILRAYC’s picture

Could anybody teach me how to add the non-cck location into a fieldgroup? It seems like this forum would be the closest and fastest to answer.

Thanks
Robert Albert Young Chu

pankajshr_jpr’s picture

Added a feature request in CCK - http://drupal.org/node/1049520