array( 'arguments' => array('element' => NULL), ), ); } /** * Implementation of hook_fieldgroup_view(). * * Hijack the theming of selected fieldgroups. */ function popups_subedit_fieldgroup_view(&$node, &$element, $group, $context) { $name = $group['group_name']; if (variable_get('popups_subedit_group_' . $name, false)) { drupal_add_js(drupal_get_path('module', 'popups_subedit') .'/popups_subedit.js'); $element['#theme'] = 'popups_subedit_fieldgroup'; $element['#node'] = $node; $element['#group_name'] = $name; } } /** * Theme the contents of a fieldgroup. */ function theme_popups_subedit_fieldgroup($element) { $name = $element['#attributes']['class']; foreach (element_children($element) as $key) { $output .= drupal_render($element[$key]); } $group_class = str_replace('_', '-', $element['#group_name']); return $output . '

' . l("Edit " . $element['#title'], 'node/' . $element['#node']->nid . '/edit', array('attributes' => array('class' => 'popups-form ', 'group_class' => $group_class))). '

'; } function popups_subedit_form_alter(&$form, $form_state, $form_id) { // dsm($form); if ($form_id == 'fieldgroup_group_edit_form') { $name = $form['group_name']['#default_value']; $form['settings']['display']['subedit'] = array( '#type' => 'checkbox', '#title' => t('Subedit'), '#default_value' => variable_get('popups_subedit_group_' . $name, 0), '#description' => t('Edit this group independantly of the rest of the node.'), '#required' => FALSE, ); $form['#submit'][] = 'popups_subedit_fieldgroup_edit_submit'; } } function popups_subedit_fieldgroup_edit_submit($form, $form_state) { dsm('popups_subedit_fieldgroup_edit_submit '); dsm($form_state['values']['settings']['display']['subedit']); $name = $form_state['values']['group_name']; variable_set('popups_subedit_group_' . $name, $form_state['values']['settings']['display']['subedit']); }