Is there a way to add custom fields into the Contact form? I don't want to have a separate webform for the info I have in mind, I'd rather have in the standard contact form.

Comments

maartenvg’s picture

Category: feature » support

this sounds more like a support request.

I've skimmed the modules list for a module that would do such a thing, but I haven't found any. In any case, you can use hook_form_alter() to create the needed fields and process them accordingly. Of course that requires programming skills.

mdowsett’s picture

which I have very little of....and I don't like altering modules (especially core modules like the contact.module) as it leaves me high-and-dry when it comes to upgrading.

thx tho

ainigma32’s picture

Status: Active » Fixed

Answer provided so I'm setting this to fixed.

Feel free to reopen or add to the issue if you know of other ways to add to the contact form.

- Arie

Status: Fixed » Closed (fixed)

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

markosaurus’s picture

Version: 5.10 » 7.0

You would use hook_form_alter() in a custom module according to the API, but I've tried that and can't get it to work;

My custom module (contactformedit) is working and enabled and I thought the following should work?

I'm trying to add a "phone" field to my sitewide contact form;

function contactformedit_form_alter(&$form, &$form_state, $form_id) {
if (isset($form['type']) && $form['type']['#value'] . 'contact_site_form' == $form_id) {
$form['phone'] = array(
'#title' => t('Your phone'),
'#type' => 'textfield',
);
}
}

No dice, I've tried alsorts and nothing works. The module is being rendered out because when I put in print 'test'; it renders that to the page, then overwrites it with the form.

Any clues anyone?

TIA