FORUMS


The Form Tools forums are no longer active, but the old posts have been archived here. Please see the Help page on how to get help / report issues.

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
If e-mail field is empty, use this address
#1
http://docs.formtools.org/userdoc/?page=...ail_fields

I would like to pinpoint first name and last name to form fields and use same e-mail (my@company.com) for all. This is because the e-mail field can be empty.

So how can I edit the code so that if the e-mail field is empty, this address (my@company.com) is used?
Reply
#2
Hey,

Huh...! So you want all emails to be sent to the same email address, regardless of the name supplied? Interesting use-case.

But you can't really do that without editing the code, unfortunately - and even that may take some work. One solution (simpler, but complete hack) would be to add a hidden field to your form like:

Code:
<input type="hidden" name="placeholder_email" value="my@company.com" />

Then use that as the recipient email. It's ugly, since it would store that dud field value in every submission, but it would work fine and let you get the job done.

- Ben

btw, AWESOME forum name. I was 100% sure you were a spammer, so your post was a nice surprise.
Reply
#3
Thank you for the answer! My question was a bit indefinite, sorry. I want the email to be sent FROM the same address, IFuser leaves the email field empty in the form.

It's a job application form, and every applicant doesn't an have e-mail address. So if the forms e-mail field is empty, the sender name and address gets messed up in the email message. It shows two senders: firstname@my.server.com, lastname@my.server.com.

So I would need to tell the Form Tools this: if the applicant doesn't have an email address, use this address instead as FROM address: my@company.com (for example).
Reply
#4
Ah, I see!

Are you using the Swift Mailer module, btw, or the default mail functionality? Just wondering, because you shouldn't see two senders: it *should* just default to "none" in the absence of a valid email address, so I'll log this as a bug.

But in the meantime, you could do this with the Submission Pre-Parser module.
http://modules.formtools.org/submission_pre_parser/

1. Just install that module, then create a new rule called "Default email address".
2. For the "When Executed" option, select either the API or "On form submission" checkboxes, depending on your form type.
3. For the PHP code section, add the following code:

PHP Code:
if (empty($_POST["email"]))
{
  
$_POST["email"] = "my@company.com";


You'll need to tweak the $_POST["email"] to whatever field name your email field has.

And that should be it!

- Ben
Reply
#5
OK, thanks! It worked. Only problem is that in this case, where user has no e-mail address, the user e-mail information is not valid in the database. Maybe I change the e-mail something like no@email.com etc... This should solve it.

I use the default e-mail functionality.

-M8R-f08t5x Wink
Reply
#6
Good post I like it
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)