I did a search for this as I thought this was simple enough that it was already answered but I couldn't find anything that matched. I have added a site-wide contact form to my Drupal site. I am wanting to remove the Subject field text box as the dropdown Category selection?

  1. How can I remove the Subject field text box?
  2. How can I make the emailed subject line come from the category selection?

TIA

Comments

rajeevk’s picture

You can do it by hook_form_alter().
Check some tutorials for it and try it...it's not hard.

Thanks,
RajeevK

Rajeev Kumar,
@drupler@bihar.social (ActivityPub)

dougthelegoman’s picture

I've got a potential solution that doesn't involve a lick of code if you're interested.

For this solution I'm going to make 2 basic assumptions.
1. You used the webform module to create your contact form.
2. You can translate my instructions from drupal 6 to drupal 7 (I'm afraid I use d6).

So here goes...
Step 1. Go to the webform. The admin tabs should be visible above the form.
2. Click the "Webform" tab.
3. Be sure that you have the sub-tab "Form components" selected.
4. You should see a table. The table should include a column with the links "edit", "clone", and "delete". In the "Subject" row click "delete"
5. The final row of this table should include the following:

    A. A field that says "New component name." Enter "Category"
    B. A listbox with the default "Textfield". Change this to "Select options".
    C. A checkbox in the "Mandatory" column. Check the checkbox.
    D. A button labeled "Add". Click the button.

6. You have now been redirected to what appears to be a new page full of settings. I would leave the first three ("Label", "Field Key", and "Default value") alone.
7. You can probably leave the "Description" alone as well.
8. "Options" is a tricky setting so let me give you an example entry:

    question|Question
    comment|Comment
    complaint|Complaint

Basically, the computer sees what you put before the line and the user sees/selects what you put after.
9. I wouldn't check the "Multiple" checkbox since you plan to use a listbox.
10. Check the "Listbox" checkbox.
11. Click Submit and enjoy!

Vako’s picture

Open the Content Type of the node that your comments are posted.
Scroll down and open the section of Comments.
You will see an option called

Comment subject field

with radio buttons of Disabled / Enabled.

I think that should do the trick.