I'm using drupal 6.19 and contact field 2.1

The issue is that I want to add several text-fields to the contact form. Particularly, I want to add "date", "location", and "phone number" When I add these fields and place them in the order I want (although order does not appear to be a factor) only one of the fields will be sent in the email to the recipient. I tried using a message template as a work-around, but that didn't work either (almost certainly because I don't have the token module installed)

As another work around, I tried changing some of the text-fields to text-areas. But I found I could only have a single text area as well. So, it appears that I can have one field of each type successfully sent via email.

My final workaround was to have a text-field for "phone number" and a text area for "date and location" but I would like to be able to have the series of text-fields as I originally planned.

To make this a little more concrete, the form that I'm working on is at http://www.idocakes.biz/contact I would be glad to provide any more information that you need.

Regards,
-Josh

Comments

beautifulmind’s picture

Hello,
Thanks for your concern and raising the issue. I appreciate it.
I understand your issue and now trying to re-generate the same on my local environment. Once tested, I'll give an url of one of my live sites where you can send a message and I'll forward the result to you.

Regards.

beautifulmind’s picture

Hello,
I've fixed the issue and you take a demo at http://joshics.in/contact. Once I've received you email, I'll forward it back to you for an observation.

Thanks for your concern and using the module. I really appreciate it.

Regards.

beautifulmind’s picture

Status: Active » Closed (fixed)

Please use the latest dev release. I'm going to add a stable release accommodating this fix soon.

Thanks for your concern and using the module. I really appreciate it.

Regards.

sparrish26’s picture

I'm having the same issue with the latest dev release (9-12-10). Only one textfield is being sent to the contact form recipient.

beautifulmind’s picture

Okay. I'll do the testing again and fix the issue.
Can you provide me the list of the fields and their configurations? It will be easy and quick for me to re-generate the issue.
Thanks for your concern and using the module. I really appreciate it.

Regards.

sparrish26’s picture

Sure thing. I set up two textfields, both with the settings below (the other settings were left to default):

Title: Phone
Name: phone
Required: Yes
Enabled: Yes

Title: Company Name
Name: company_name
Required: No
Enabled: Yes

I did some testing on it, and determined that regardless of the weight that is set, the first one inserted into the database is the one that will be delivered in the email. Let me know if you need any more information. Thanks!

beautifulmind’s picture

Hello,
This will do.
Thanks for providing the information. I will work it out.

Regards.

JoshOrndorff’s picture

Version: 6.x-2.1 » 6.x-2.2

Hi again,

Thanks for all of the work you've done on this issue. Today I upgraded to version 2.2 of contact field (still using drupal 6.19), and I still have the same issue. When I add multiple text fields, the email only contains the first one.

I would be glad to provide whatever additional information you need. I'll also take a look through the code myself and try to help out, but I have little experience with the API, so I might not be much help.

Thanks again,
-Josh

JoshOrndorff’s picture

And this appears to still be happening in the latest 2.x-dev version (12 September 2010)

JoshOrndorff’s picture

Status: Closed (fixed) » Needs review

Okay, I think I've found and corrected the problem. This is my first time ever contributing code to a module, and also my first time ever using diff, so if I screwed something up, please let me know so that I can get it right in the future.

It looks like hook_mail_alter which generates the email was iterating through every type of field, but not every instance of a field within that type. I created a simple for loop to iterate through the instances like the one that is used when a message template is being used a few lines later. This solves my problem as far as I've tested it.

I have not tested anything at all using a message template, but it looks like there may be another small error in that section of code in this line:
$ss__value = _get_field_setting($as__field[0], $message['params'][$as__field[$i]]);
I wonder if the hard-coded 0 is supposed to be a $i ? I'm not sure because I'm not that familiar with the code, but I thought I'd mention it.

Let me know if there is anything else I can do to help.

-Josh

JoshOrndorff’s picture

StatusFileSize
new1.09 KB

I forgot to attach the patch. Here it is.

bleen’s picture

JoshOrndorff: Congrats on your first patch! Welcome...

If you can, you should take a quick look at the Drupal coding standards at http://drupal.org/coding-standards. For example, we don't use tabs, but rather two spaces... (believe me, I still get lots of these wrong, just ask David_Rothstein :) )

There are a couple tools to help with coding standards:

http://drupal.org/project/coder - this module will examine your code and yell at you about coding sandards...

Also, if you use firefox, you might want to install the greasemonkey add on and then go to http://drupal.org/project/dreditor ... then come back to this page and you will see a "review" button in comment #11. Clicking it will show you some whitespace issues problems AND help you review patches

beautifulmind’s picture

Hello,
I've been working hard to fix the issue. I'm testing the module on all of my live sites as well as few other sites. But the issue is no apprearing on all the sites. But I will fix it anyway.

Regards.

JoshOrndorff’s picture

StatusFileSize
new1.18 KB

bleen18: Thanks a lot for the tips about coding standards. I've fixed the leading and trailing white space, and made sure to use spaces around my operators. That Dreditor script is pretty awesome. I also read over the rest of the coding standards, although I'm sure I'll have to keep looking back at them

beautifulmind: I've submitted an updated patch if it will help you out fixing the problem. I think just adding that simple for loop takes care of it. If you want to reproduce the problem, here is exactly what I did:

From a fresh install of drupal 6.19
Enable core's contact module.
Specify four different categories of messages with a single email recipient for each category
Install contact field 6.x-2.2 (or 2.1) and everything that comes in the tar.gz file
Enable only contact_field.module and contact_textfield.module
Add three text fields and zero text areas to the contact form.
Do not use any message templates
Send a test email

With this configuration, I find that the email's "Additional Information" section only contains one of the three textfields (the first one created) and omits the other two.

Thanks so much for making this module, and working hard to solve the issue. Let me know if there is anything else I can do to help.

-Josh

boran’s picture

Just tried v2.2 stable, then dev today, same issue.

However after creating a message template it worked file.

advancebrain’s picture

Hello All,

I have used this module and it was more helpful for me.

Also I have faced one similar issue with this module.

If we are using the message template and sending mail with punctuations like ' , " , etc. it is sending the html entity of the corresponding punctuation via mail.

I solved this issue for now but not sure it is valuable.

In contact_field.module I replaced $am__value['!message'] = check_plain($message['body'][1]); with following:

$am__value['!message'] = $message['body'][1];

Thanks.

beautifulmind’s picture

Hello,
If you try the latest dev version, the issue has been fixed.

Regards.

ibis’s picture

Hello beautifulmind,

apply the patch manually from #14 to .dev and make new dev release (or new 2.2 release)!
(The issue is live on mail sending without template).

Regards.

beautifulmind’s picture

Status: Needs review » Closed (fixed)

Hello,
The issue has been fixed in latest development release.

Thank you for your concerns and using the module.

Regards.

frosty29’s picture

Status: Closed (fixed) » Needs work

Hi, i had this issue (not more than one additional text field being sent) - I tried the fix suggested in http://drupal.org/node/1320752 which didn't work and quickly wrote a fix which turns out similar to that above [#14]. I was going to contribute it and only then found and read this thread and have now tried dev version as suggested - it is certainly not fixed there?

JoshOrndorff’s picture

Yeah, it definitely isn't fixed. I've just been using my own patch from #14.

beautifulmind’s picture

Hello,
Please try the dev release in 6.x branch. That should fix the issue.

Regards.

beautifulmind’s picture

Version: 6.x-2.2 » 6.x-2.x-dev
Status: Needs work » Closed (works as designed)
mpv’s picture

Status: Closed (works as designed) » Active
StatusFileSize
new1.28 KB

I have had this issue previously, with older versions of the module, so i set up a drupal 6.24 clean install to test 6.x-2.x-dev. I can confirm the issue isn't resolved. I will try to be as clear as possible:

  • I installed drupal 6.24
  • Enabled contact, contact_field, contact_listfield, contact_option and contact_textfield
  • Added two tetxfields, one option field, one list field and one textarea field to the contact form
  • I'm not using a message template
  • Only the first field of each type is added to the body of the mail

Looking at the code in contact_field_mail_alter I can see that for each type of fields, the variables $as__title and $as__field hold the values and names for all the fields of each type, but then only the first one is used (lines 312 through 317 use $as__title[0] and $as__field[0]).

Attached is a patch against the 6.x-2.x branch that adds a loop through all the fields of each type when adding them to the message.
The fix is for the case when a message template is not used.

This is the fix i've been using. Is similar to the one listed in #1320752: Only one field of each type returned in e-mail.

beautifulmind’s picture

Status: Active » Closed (cannot reproduce)
ericwongcm’s picture

Status: Closed (cannot reproduce) » Reviewed & tested by the community

Re: #24 patch

Your patch fixed the same problem I experienced on contact_field-6.x-2.x-dev (2011-Feb-25).

What I had was two list fields and only one of them would be returned in the e-mail submitted.

Please add this patch to the module, so others will benefit when using this module.

Thanks

kenorb’s picture

Issue summary: View changes
Status: Reviewed & tested by the community » Fixed

Patch #24 fixes the problem as described. If you're having different issue, please raise a new ticket or specify which patch wasn't committed.

Status: Fixed » Closed (fixed)

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