All blocks for any category always use the selected category. The blocks are created correctly and show up as configured destictively but when the user clicks send, every email arrives at the mailbox for the selected default category.

I've setup multiple categories working correctly with or withoug contact forms module. Using the site wide default contact form (/contact) and selecting a category also works as exprected. It's just the individual blocks for categories that do not use their own category.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

ronny89’s picture

the same happens on my installation.
i know it worked once, but at some point the described behaviour arised. unfortuantely i can't determine that point in time. but i'm quiet sure it wasn't the latest update.
@spacebox, have you yet tried to disable any other modules to see if something is interfering?

guy_schneerson’s picture

I am getting the same issue the looks like the problem is in replacing the 'select' field of the contact form with a 'value' element. The value of cid just dosen't make it to the form submit.
I have fixed this by using another approach insted of replacing the 'cid' form element I hide it using 'style' = 'display: none;'

This is not elegant as I need to hide the title and the required flag (safe to do because we are setting the value in code) but it works.
Another approach may be to hide the element in a hook_form_alter()

will post a patch of my code in a bit

guy_schneerson’s picture

Status: Active » Needs review
FileSize
995 bytes

Patch for above

guy_schneerson’s picture

Form submit error: "You must select a valid category" is the same issue and comment #3 proposed a simpler solution that needs testing.

lnfra’s picture

Issue summary: View changes

Why use a select when you can use a hidden?

I just replace the line 102 of contact_form_blocks.module which originally is like

$form['cid'] = array('#type' => 'value', '#value' => $category);

The problem here is that the type of the form element is added as "value" and that is not a valid HTML form element. It doesn't get added to the form by drupal_render($form).

In order to correct the bug I just replaced that line with a prober hidden type element with the category value:

$form['cid'] = array('#type' => 'hidden', '#name' => 'cid', '#value' => $category);

And it works correctly!