Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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.
Comment | File | Size | Author |
---|---|---|---|
#3 | mail_sent_with_default_cat-1675940-3.patch | 995 bytes | guy_schneerson |
Comments
Comment #1
ronny89 CreditAttribution: ronny89 commentedthe 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?
Comment #2
guy_schneerson CreditAttribution: guy_schneerson commentedI 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
Comment #3
guy_schneerson CreditAttribution: guy_schneerson commentedPatch for above
Comment #4
guy_schneerson CreditAttribution: guy_schneerson commentedForm submit error: "You must select a valid category" is the same issue and comment #3 proposed a simpler solution that needs testing.
Comment #5
lnfra CreditAttribution: lnfra commentedWhy 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!