For new contact and organization types, I am using field_group for multipage entry. This is because we have a large amount of entry fields for both types and this is easier on our users, who mostly will be maintaining a large number of these contacts. We are able to use multipage grouping with great results while adding a contact, however when we try doing this with an organization, the default "Name" field will simply not cooperate and stays outside of the multipage group. I tried looking at the modules included form.inc files to pin down the difference in the form creation but I need a nudge in the right direction. What could possibly create a situation where this works on Contacts but not Organizations?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

levelos’s picture

Category: bug » support

Re-categorizing as a support request. We've never used a multi-page field group, so don't any specific to offer. Happy to leave this open in case someone else can help.

kevinquillen’s picture

Title: RedHen Orgs and field_group Multipage support » RedHen Orgs and field_group support

This problem persists even if you are not doing a multipage form.

Install RedHen Organizations, and add some fields from the Field UI. Enable Field Group module. Create a few groups of type Vertical Tab. Nest your new Fields in them, using each one. Then go to create an Organization. Everything is neatly organized in their respective tabs except the Name property.

The reason for this is in redhen_forms.inc line 20:


$form['label'] = array(
    '#type' => 'textfield',
    '#title' => t('Name'),
    '#default_value' => $org->label,
    '#maxlength' => 255,
    '#required' => TRUE,
    '#weight' => -6,
  );

  // Add the field related form elements.
  $form_state['redhen_org'] = $org;
  field_attach_form('redhen_org', $org, $form, $form_state);

No matter what you do, "Name" is added in outside of anyones control and unable to be grouped or sorted. He is asking for it to be like Nodes, where 'Title' is a node specific field defined in its module, but still able to be sorted on the Manage Fields page of the admin. This effectively lets you leverage Field Groups to control the grouping and layout of your entry forms. I would say this is more of a bug than support, but that is your call.

I have moved Organization Name all over Manage Fields, and despite it being in the $form array on the add/edit page, it does not appear. "Name" always appears at the top of the form.

asherry’s picture

In the redhen_contact module, the field name is wrapped in a container. That allows you to change the weight. When I did the same for the redhen_org label field it worked the same way.

Both the redhen_org:label and the redhen_contact:name fields though, if their container does not have a #type attribute, they will get removed in line 958 of field_groups.module. I just simply added a #type => 'container'.

I made a patch that seems to work for me, and doesn't screw up any actual data saving.

asherry’s picture

FileSize
1.45 KB

This is actually a patch for both redhen_contact and redhen_org, should I make two patches and post them to issues for the right submodules?

asherry’s picture

Status: Active » Needs review
nedjo’s picture

Category: support » feature

Using containers also has theming advantages.

+++ b/modules/redhen_org/includes/redhen_org.forms.inc
@@ -19,13 +19,14 @@ function redhen_org_add($type) {
-    '#weight' => -6,
+//   '#weight' => -6,

Looks like some stray commenting out here. Or is there a reason to delete the #weight property?

asherry’s picture

FileSize
1.31 KB

Sorry about the comment. No, there is no benefit or reason to take out the #weight property, that's actually what I was verifying by commenting it out. I meant to uncomment it. It doesn't actually do anything by itself though, but I think it would be handy if anybody or any other module does a form_alter and adds elements to the ['name'] container.

Here is another patch.

levelos’s picture

Status: Needs review » Fixed

Thanks asherry, committed.

Automatically closed -- issue fixed for 2 weeks with no activity.

  • Commit ed790f8 on 7.x-1.x, tests, redhen-donation authored by asherry, committed by levelos:
    #1794948 by asherry: Change form name elements to be of type container.
    

  • Commit ed790f8 on 7.x-1.x, tests, redhen-donation, relation-roles authored by asherry, committed by levelos:
    #1794948 by asherry: Change form name elements to be of type container.
    
jhoffmcd’s picture

Version: 7.x-1.x-dev » 7.x-1.12
Assigned: Unassigned » jhoffmcd
Issue summary: View changes
Status: Closed (fixed) » Needs work

This seems to have resurfaced again with an update to the latest version 7.x-1.12. A simple patch should fix it.

jhoffmcd’s picture

Here's a patch for just the original problem, it's the same fix provided by asherry but without the Redhen contact form fix.

jhoffmcd’s picture

Status: Needs work » Needs review

  • gcb committed 72e5d92 on 7.x-1.x authored by jhoffmcd
    Issue #1794948 by asherry, jhoffmcd: RedHen Orgs and field_group support
    
gcb’s picture

Status: Needs review » Fixed

Thanks @jhoffmcd!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

asherry’s picture