You are here

function content_type_groups_group_form_submit in Content type groups 7

Same name and namespace in other branches
  1. 7.2 content_type_groups.admin.inc \content_type_groups_group_form_submit()

Submit handler for form content_type_groups_group_form

File

./content_type_groups.admin.inc, line 175
Admin page callback file for the Content type groups module.

Code

function content_type_groups_group_form_submit($form, &$form_state) {
  $group = new ContentTypeGroup($form_state['values']['type']);
  $group->name = $form_state['values']['name'];
  $group->content_types = array();
  foreach ($form_state['values'] as $field => $val) {
    if (strpos($field, 'checked-') === 0 && $val == 1) {
      $content_type = substr($field, 8);

      // Get the rest of the field name after 'checked-'
      $group
        ->addContentType($content_type, $form_state['values']['weight-' . $content_type]);
    }
  }
  $group
    ->save();
  drupal_set_message(t('Content type group %group has been saved.', array(
    '%group' => $group->name,
  )));

  //$form_state['redirect'] = 'admin/structure/types/groups';
}