I am new to Chronoforms but so far have had good success setting up a form in J1.5 capturing some basic data such as:
Name
Email Address
Selection Option
Date
(and also seem to be successful using validation)
I would like to include BOTH values Selected Option and Date in the Subject Line of the email message that is consequently emailed.
How do I do this?
Many thanks
symbic
Try this code in the 'Onsubmit before' box
<?php
$rows[0]->emailsubject = "Some text".$_POST['first_fieldname']." "$_POST['second_fieldname']." some more text";
?>
The code you supplied in your previous post looks like it is exactly what I need, however I can't seem to get it working. Is this something that you have used with Chronoforms, and if so is there anything else I need to do to get it working... i.e. placing a variable in the special fields subject field...
Thank you for your help,
Sam
Turn debug on and you'll see the values that are being returned by the form.
Add one more line to the code:
<?php
$rows[0]->emailsubject =
"Some text".$_POST['first_fieldname']."
".$_POST['second_fieldname']." some more text";
if ($debug) {
echo "subject; ";print_r($rows[0]->emailsubject);echo "<br />";
}
?>
This should print out the value of the subject as long as debug is turned on.
Bob
I've tried the code you have suggested but can't seem to get it to work correctly.
The email is sent and shows ONE of the fields in the subject line but I also end up seeing a Parse error on the resulting thankyou page
Parse error: syntax error, unexpected T_VARIABLE in
/home/account/public_html/subdomain/components
/com_chronocontact/chronocontact.php(425)
: eval()'d code on line 2
E-mail: 'Yes' custom
Email sent
(If the Subject Field under the Special Fields tab is left blank then it seems to default to the Email Subject shown under the General Tab, regardless of using the code above)
Thanks
Denise
Sorry there was a dot '.' missing before the second $_POST - I've put it back in my pevious post.
Bob
hmmm... still getting a Parse error:
Parse error: syntax error, unexpected ':' in
/home/domain/public_html/subdomain/components/
com_chronocontact/chronocontact.php(425)
: eval()'d code on line 4
E-mail: 'Yes' custom
Email sent
E-mail message
and it shows default Email Subject
?? again if the Subject Field under the Special Fields tab is left blank then it seems to default to the Email Subject shown under the General Tab, regardless of using the code suggested.
Any further ideas??
many thanks
Not my day, there was a second typo in the next line a : instead of a ; - also fixed now.
Bob
All working nicely now with both fields displayed in subject line along with set text
(Note I left Subject Field blank under the Special Fields tab)
Chronoforms has ended up providing very nice solution for what i needed.
thanks again
Denise
Thank you so much for this fix!
I have a similair Problem. I want to combine 3 fields (voornaam tussennaam naam) in the email from name of the email.
Therefore I made this code :
<?php
$rows[0]->emailnaam = $_POST['voornaam']." ".$_POST['tussennaam']." ".$_POST['naam'];
if ($debug) {
echo "subject; ";print_r($rows[0]->emailnaam);echo "<br />";
}
?>
But I do only get the emailaddress in the from field ? (I filled emailnaam in the Dynamic Fromname field of the email setup tab.)
The output of the debug is ok.
Patrick
Which versions of ChronoForms and Joomla are you using (apologies if we've already asked this - I don't remember)? The code here was for Joomla 1.0.x
Bob
try to make it :
$emails[0]->subject = JRequest::getVar('firstname')." ".JRequest::getVar('lastname');
!replace fields names with yours!put this cod in the onsubmit before email!
Regards
Max
this looks better.
I added the php tags to the code <?php and ?> at the end. But I do not want to use the "subject" field but the "Dynamic name from" field. Which variable should I use instead?
Isn't there a nice way to combine these fields in the email template fields ?
Thx
Patrick
use dfromname instead of subject then!
nicer way? how ?
Max
either I do something wrong or it is not working😟
This is my code :
<?php
$emails[0]-> dfromname = JRequest::getVar('voornaam')." ".JRequest::getVar('tussennaam')." ".JRequest::getVar('naam');
?>
What I mean with nicer, is that you can enter multiple fields into the emailsetup tab for example dynamic fromname.
Now is only one field allowed.
best
Patrick
Each email can have only 1 from name and 1 from email!
don't leave a space between the dfromname and the > in your code!
Max
<?php
$emails[0]->dfromname = JRequest::getVar('tbLName').", ".JRequest::getVar('tbFirstName');
?>
Could you please tell me what is wrong with this?
Try without the comma - that may be being treated as a special character.
Bob
<?php
$emails[0]->dfromname = JRequest::getVar('tbLName');
?>
and that still didn't work
<div class="form_item">
<div class="form_element cf_textbox">
<label class="cf_label">First Name:</label><a class="tooltiplink" onclick="return false;"><img height="16" border="0" width="16" class="tooltipimg" src="components/com_chronocontact/css/images/tooltip.png"/></a><br />
<input class="cf_inputbox required" id="text_10" name="tbFirstName" type="text" />
<div class="tooltipdiv">First Name: :: Please enter your first name</div>
</div>
<div class="clear">Â </div>
</div>
<div class="form_item">
<div class="form_element cf_textbox">
<label class="cf_label">Last Name:</label><a class="tooltiplink" onclick="return false;"><img height="16" border="0" width="16" class="tooltipimg" src="components/com_chronocontact/css/images/tooltip.png"/></a><br />
<input class="cf_inputbox required" id="text_9" name="tbLName" type="text" />
<div class="tooltipdiv">Last Name: :: Please enter your last name</div>
</div>
<div class="clear">Â </div>
</div>
<div class="form_item">
<div class="form_element cf_textbox">
<label class="cf_label">Address:</label><a class="tooltiplink" onclick="return false;"><img height="16" border="0" width="16" class="tooltipimg" src="components/com_chronocontact/css/images/tooltip.png"/></a><br />
<input class="cf_inputbox required" id="text_8" name="tbAddress" type="text" />
<div class="tooltipdiv">Address: :: Please enter your address</div>
</div>
<div class="clear">Â </div>
</div>
<div class="form_item">
<div class="form_element cf_textbox">
<label class="cf_label">APT/Building/Room/Suite</label><a class="tooltiplink" onclick="return false;"><img height="16" border="0" width="16" class="tooltipimg" src="components/com_chronocontact/css/images/tooltip.png"/></a><br />
<input class="cf_inputbox" id="text_5" name="tbAddress2" type="text" />
<div class="tooltipdiv">APT/Building/Room/Suite :: Please enter your apt, building, room, or suite number</div>
</div>
<div class="clear">Â </div>
</div>
<div class="form_item">
<div class="form_element cf_dropdown">
<label class="cf_label">State:</label>
<a class="tooltiplink" onclick="return false;"><img height="16" border="0" width="16" class="tooltipimg" src="components/com_chronocontact/css/images/tooltip.png"/></a>
<br />
<select class="cf_inputbox validate-selection" id="select_7" size="1" {cf_multiple} name="ddState">
<option value="">Choose Option</option>
<option value="Indiana">Indiana</option>
<option value="Ohio">Ohio</option>
</select>
<div class="tooltipdiv">State: :: Please select your state.</div>
</div>
<div class="clear">Â </div>
</div>
<div class="form_item">
<div class="form_element cf_textbox">
<label class="cf_label">Zip Code:</label><a class="tooltiplink" onclick="return false;"><img height="16" border="0" width="16" class="tooltipimg" src="components/com_chronocontact/css/images/tooltip.png"/></a><br />
<input class="cf_inputbox required validate-number" maxlength="5" size="5" id="text_4" name="tbZip" type="text" />
<div class="tooltipdiv">Zip Code: :: Please enter your zip code</div>
</div>
<div class="clear">Â </div>
</div>
<div class="form_item">
<div class="form_element cf_textbox">
<label class="cf_label">Phone Number:</label><a class="tooltiplink" onclick="return false;"><img height="16" border="0" width="16" class="tooltipimg" src="components/com_chronocontact/css/images/tooltip.png"/></a><br />
<input class="cf_inputbox required" id="text_3" name="tbPhone" type="text" />
<div class="tooltipdiv">Phone Number: :: Please enter your phone number.</div>
</div>
<div class="clear">Â </div>
</div>
<div class="form_item">
<div class="form_element cf_textbox">
<label class="cf_label">Email:</label><a class="tooltiplink" onclick="return false;"><img height="16" border="0" width="16" class="tooltipimg" src="components/com_chronocontact/css/images/tooltip.png"/></a><br />
<input class="cf_inputbox required validate-email" id="text_2" name="tbEmail" type="text" />
<div class="tooltipdiv">Email: :: Please enter your email address</div>
</div>
<div class="clear">Â </div>
</div>
<div class="form_item">
<div class="form_element cf_datetimepicker">
<label class="cf_label">Party Date:</label><a class="tooltiplink" onclick="return false;"><img height="16" border="0" width="16" class="tooltipimg" src="components/com_chronocontact/css/images/tooltip.png"/></a><br />
<input class="cf_datetime required" maxlength="2147483647" size="20" id="date_1" name="dtParty" type="text" />
<div class="tooltipdiv">Party Date: :: Please choose when you would like to have your party.</div>
</div>
<div class="clear">Â </div>
</div>
<div class="form_item">
<div class="form_element cf_textarea">
<label class="cf_label">Comments:</label><a class="tooltiplink" onclick="return false;"><img height="16" border="0" width="16" class="tooltipimg" src="components/com_chronocontact/css/images/tooltip.png"/></a><br />
<textarea class="cf_inputbox" rows="5" id="text_0" cols="30" name="taComments"></textarea>
<div class="tooltipdiv">Comments: :: Please enter any comments or questions</div>
</div>
<div class="clear">Â </div>
</div>
<div class="form_item">
<div class="form_element cf_button">
<input value="Submit" type="submit" />
</div>
<div class="clear">Â </div>
</div>
try to add a dynamic from name to your form and see if it comes with the email ?
Max
Hi jdpickering,
try to add a dynamic from name to your form and see if it comes with the email ?
Max
I attached a screenshot of my "Setup Email" and I have a To, Subject, Dynamic Fromname, and Dynamic FromEmail
[attachment=0]screenshot.jpg[/attachment]
Here is what I've put "On Submit Code - before sending email"
<?php
$emails[0]->dfromname = JRequest::getVar('tbLName')." ".JRequest::getVar('tbFirstName');
if ($debug) {
echo "FromName; ";print_r(JRequest::getVar('tbLName')." ".JRequest::getVar('tbFirstName'));echo "<br />";
echo "dfromname; ";print_r($emails[0]->dfromname);echo "<br />";
}
?>
Here is the Debug of my code and it appears its setting the right variable
_POST: Array ( [tbFirstName] => Joe [tbLName] => Pickering [tbAddress] => 123 Rainbow [tbAddress2] => [ddState] => Ohio [tbZip] => 55555 [tbPhone] => 555-555-5555 [tbEmail] => [email]test@domain.net[/email] [dtParty] => 3/13/2009 [taComments] => test [5f94541d4e96e6311c252bc917c2a875] => 1 )
FromName; Pickering Joe
dfromname; Pickering Joe
E-mail message
From: [test@domain.net]
To: [email]user@domain.com[/email]
Subject: test
First Name:
Joe
Last Name:
Pickering
Address:
123 Rainbow
APT/Building/Room/Suite
State:
Ohio
Zip Code:
55555
Phone Number:
555-555-5555
Email:
[email]test@domain.net[/email]
Party Date:
3/13/2009
Comments:
test
Max
and when you test this, what do you get in the from name of the email ?
Max
I get nothing I guess you would say I get the email address as the From name instead of saying Pickering Joe as who it is from I get [email]Test@domain.net[/email]
Cheers
Max