i have found a little bug, if i place field to be edited by comment, inside fielgroup, it doesnt appear in comments form.

CommentFileSizeAuthor
#2 field_group_comp.patch5.01 KBandyhu

Comments

andyhu’s picture

Plese add this line after line 50 ($form['#validate'][] = 'cne_form_validate';)

    $form['#pre_render'] = array_unique($form['#pre_render']);

It should fix the problem

andyhu’s picture

StatusFileSize
new5.01 KB

Here is the patch, please test

dgastudio’s picture

sorry, both of proposed solutions doesnt works..

fielgroup is still attached to comments form...

eric.chenchao’s picture

In my observation, when we programmatically call field_attach_form to get node attached fields in the comment form. The field group pre render functions will be called twice, which make all nodes fields be removed in the comment form.

But if we Field API to create a new field and use field_attach_form() in the field widget form. There is no problem.

Here is the solution. Add this code in the module file and clear the cache. It should work.

/**
 * Implements hook_module_implements_alter()
 */
function cne_module_implements_alter(&$implementations, $hook) {
  if ($hook == 'field_attach_form') {
    // The field_group module has an issue when use field_attach_form twice in the same form.
    // For exmaple call field_attach_form programmatically to get node attached fields in the comment form.
    // So we have check field_group_field_attach_form has been only called once
    if (module_exists('field_group')) {
      unset($implementations['field_group']);
    }
  }
}

/**
 * Implements hook_field_attach_form().
 *
 * When use field_attach_form programmatically to get nodes fields in the comment form for example,
 * field_group_field_attach_form should be only called once.
 */
function cne_field_attach_form($entity_type, $entity, &$form, &$form_state, $langcode) {
  if (module_exists('field_group')) {
    if ($entity_type == 'node' && isset($form['#id']) && $form['#id'] == 'comment-form') {
      return;
    }
    else {
      field_group_field_attach_form($entity_type, $entity, $form, $form_state, $langcode);
    }
  }
}