I'm porting a Drupal 6 module to Drupal 7. In Drupal 5 & Drupal 6, there was a Workflow section in the Content Types area and the additional fields went there. This is gone in Drupal 7. I tried to add a custom section, but it's not working at all.
Here is my code:
/** * Implements hook_form_alter() - adds fields to Content Type forms. */ function phpfreechat_form_alter(&$form, &$form_state, $form_id) { global $user; $type = (isset($form['type']) && isset($form['type']['#value'])) ? $form['type']['#value'] : NULL; $node = isset($form['#node']) ? $form['#node'] : NULL; if ($form_id == 'node_type_form' && isset($form['identity']['type'])) { // Content-type edit form // Define field set in additional settings group $form['phpfreechat'] = array( '#type' => 'fieldset', '#title' => t('phpFreeChat settings'), '#collapsible' => TRUE, '#collapsed' => TRUE, '#weight' => 10, '#group' => 'additional_settings', ); $form['phpfreechat']['phpfreechat_nodeapi'] = array( '#type' => 'radios', '#title' => t('Show chat room'), '#default_value' => variable_get('phpfreechat_nodeapi_' . $form['#node_type']->type, 'never'), '#options' => array( 'never' => t('Never'), 'always' => t('Always'), 'pernode' => t('Per Node'), ), '#description' => t('None: Nodes of this content type can never have a chat room.
' . 'Always: Nodes of this content type will always have a chat room.
' . 'Per Node: Nodes of this content type can choose to have a chat room if desired.'), ); $form['phpfreechat']['phpfreechat_nodeapi_custom'] = array( '#type' => 'checkbox', '#title' => t('Allow node to set title & channels'), '#return_value' => 1, '#default_value' => variable_get('phpfreechat_nodeapi_custom_' . $form['#node_type']->type, ''), '#description' => t('If this is checked then node editors will be able to set the chat ' . 'title and select what channels to join.'), ); $form['phpfreechat']['phpfreechat_nodeapi_title'] = array( '#type' => 'textfield', '#title' => t('Default Chat Channel Title'), '#default_value' => variable_get('phpfreechat_nodeapi_title_' . $form['#node_type']->type, ''), '#size' => 70, '#maxlength' => 128, '#description' => t('This is the default channel title for this content type. ' . 'Leaving this blank will use the global or node chat ' . 'title, or the node title if these are also blank.'), ); $form['phpfreechat']['phpfreechat_nodeapi_channels'] = array( '#type' => 'textfield', '#title' => t('Default Chat Channels'), '#default_value' => variable_get('phpfreechat_nodeapi_channels_' . $form['#node_type']->type, ''), '#size' => 70, '#maxlength' => 128, '#description' => t('Enter the default channel or channels to be joined for this content type. Separate multiple channels by commas (e.g. Channel1, Channel2). If you leave this blank, it will default to the global node channel(s), or the node title if this is also blank.'), ); } elseif (isset($form['type'])) { // Node edit form // Define field set in additional settings group if (phpfreechat_nodedata($type) && user_access($permission_create_chatboxes)) { $form['phpfreechat'] = array( '#type' => 'fieldset', '#title' => t('phpFreeChat Settings'), '#collapsible' => TRUE, '#collapsed' => TRUE, '#weight' => 10, '#group' => 'additional_settings', ); if (variable_get('phpfreechat_nodeapi_' . $form['type']['#value'], 'never') == 'pernode') { $form['phpfreechat']['phpfreechat_enabled'] = array( '#type' => 'checkbox', '#title' => t('Show Chat Room'), '#return_value' => 1, '#default_value' => ($node->phpfreechat_enabled == 1 ? TRUE : FALSE), '#description' => 'If this is selected a chat room will be displayed below the content', ); } if (variable_get('phpfreechat_nodeapi_custom_' . $form['type']['#value'], '') == TRUE) { $form['phpfreechat']['phpfreechat_title'] = array( '#type' => 'textfield', '#title' => t('Chat Channel Title'), '#default_value' => $node->phpfreechat_title, '#size' => 70, '#maxlength' => 128, '#description' => t('This is the chat title. You can leave this blank to use the default.'), ); $form['phpfreechat']['phpfreechat_channels'] = array( '#type' => 'textfield', '#title' => t('Chat Channel'), '#default_value' => $node->phpfreechat_channels, '#size' => 70, '#maxlength' => 128, '#description' => t('Enter the channel or channels to be joined for this chat. Separate multiple channels with commas (e.g. Channel1, Channel2). You can leave this blank to use the default.'), ); } } } }
I posted it on the Drupal forum, but they're too arrogant to answer questions over there. They ignore everything I post.
<pre>
).