Hi,

the referenced node is not showing the name of the group fields. What is the solution?

Thanks

Comments

JaapB’s picture

You can create working groups with "hook_node_widget_form_alter()" and a custom submit function... but it's quite a bit of crappy programming.

Use this to create a group into the child-node's form and move fields into it:

function HOOK_node_widget_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'CHILD_node_widget_form') {
    // Create group.
    $form['#field_info']['GROUP'] = array();
    $form['GROUP'] = array(
      '#type' => 'fieldset',
      '#title' => t('GROUP'),
      '#tree' => TRUE
    );
    // Add fields to group and remove it's original one.
    $form['#field_info']['GROUP']['FIELD'] = $form['#field_info']['FIELD'];
    $form['GROUP']['FIELD'] = $form['FIELD'];
    unset($form['FIELD'], $form['#field_info']['FIELD']);
  }
}

Then create a custom submit handler to the parent form.
And make sure it is called before other submit functions.

function HOOK_form_alter(&$form, $form_state, $form_id) {
  if ($form_id == 'PARENT_node_form') {
    $form['#submit'] = array_merge(array('HOOK_node_widget_form_submit'), $form['#submit']);
  }
}

Put the fields back into the form_state without the group.

function HOOK_node_widget_form_submit(&$form, &$form_state) {
  $form_state['values']['field_REFERENCED'][0]['node_widget']['FIELD'] = $form_state['values']['field_REFERENCED'][0]['node_widget']['GROUP']['FIELD'];
}

But it would be better if this module just supported field_groups ;-)