Hello everyone,
I have a basic form wich stores data in the database and sends the form to a email adress. But I have a custom dropdown field with "Urgent". If "Urgent" is set to NO than the form only needs to be stored in the database. If "Urgent" is set to YES the form needs to be stored in the database and needs to be sent to a specified (always the same) mail adres.
I have no idea how to archieve this. Hope you can help me out!
THANKS!!!
Kindest regards,
Jarno
I have a basic form wich stores data in the database and sends the form to a email adress. But I have a custom dropdown field with "Urgent". If "Urgent" is set to NO than the form only needs to be stored in the database. If "Urgent" is set to YES the form needs to be stored in the database and needs to be sent to a specified (always the same) mail adres.
I have no idea how to archieve this. Hope you can help me out!
THANKS!!!
Kindest regards,
Jarno
HI Jarno,
It's tricky to interactively turn the ChronoForms email on and off but try this in the OnSubmit Before box:
Bob
It's tricky to interactively turn the ChronoForms email on and off but try this in the OnSubmit Before box:
<?php
$urgent =& JRequest::getString('urgent', 'NO', 'post');
if ( $urgent == 'NO' ) {
$email->enabled = false;
}
?>
Bob
Hello Bob,
THANK YOU so much for your help. Sadly this does not work.
This is the actual field (istead of urgent it is "Ter" (Dutch) with the values "Informatie" - "AfwachtingAntwoord".
<select size="1" name="Ter" id="ter" class="contactfield" >
<option value="Informatie">Informatie</option>
<option value="AfwachtingAntwoord">Afwachting Antwoord</option>
</select>
This is the script I use in Before Submit:
It still sends the mail if the field has the value "Informatie". The form only needs to be send when the value is "AfwachtingAntwoord"
Hope you can help me out!
Thank you!
THANK YOU so much for your help. Sadly this does not work.
This is the actual field (istead of urgent it is "Ter" (Dutch) with the values "Informatie" - "AfwachtingAntwoord".
<select size="1" name="Ter" id="ter" class="contactfield" >
<option value="Informatie">Informatie</option>
<option value="AfwachtingAntwoord">Afwachting Antwoord</option>
</select>
This is the script I use in Before Submit:
<?php
$Ter =& JRequest::getString('Ter', 'AfwachtingAntwoord', 'post');
if ( $Ter == 'AfwachtingAntwoord' ) {
$email->enabled = false;
}
?>
It still sends the mail if the field has the value "Informatie". The form only needs to be send when the value is "AfwachtingAntwoord"
Hope you can help me out!
Thank you!
Hi Jarno,
Bother !! It was worth a try, I'll take another look in the morning. Are you using ChronoForms v3.0 on Joomla 1.5?
Bob
Bother !! It was worth a try, I'll take another look in the morning. Are you using ChronoForms v3.0 on Joomla 1.5?
Bob
Hi, use $email->enabled = '1';
cheers
Max
cheers
Max
Dear Bob,
Thank you. It was indeed worth a try. I hope you can figure out how to make this work. Yes I use Joomla 1.5 and the latest release of Chronoforms (3).
___________________________
Dear Max,
I changed mij code in:
Is this what you ment?? Sadly this also does not do the trick. I hope you can help me out!
Kindest regards,
Jarno
Thank you. It was indeed worth a try. I hope you can figure out how to make this work. Yes I use Joomla 1.5 and the latest release of Chronoforms (3).
___________________________
Dear Max,
I changed mij code in:
<?php
$Ter =& JRequest::getString('Ter', 'AfwachtingAntwoord', 'post');
if ( $Ter == 'AfwachtingAntwoord' ) {
$email->enabled = '1';
}
?>
Is this what you ment?? Sadly this also does not do the trick. I hope you can help me out!
Kindest regards,
Jarno
To be sure I will note my settings here.
TAB: General:
Form name: Opmerkingenformulier
Email the results: Yes
Other fields: Default after installation
TAB: Setup emails:
To: My Email address
Subject: Opmerkingen formulier ST Intranet
From name: ST intranet
From mail: [email]website@cvt-intranet.nl[/email]
TAB: Form Code:
Form HTML:
On Submit code - before sending email:
(PHP code with tags)
TAB DB Connection:
Enable data storage: Yes
Database to store is selected
Autogenerated code:
Save data/email order: After email
Autogenerated:
All the other fields ar default as they where after the installation of Chronoforms.
Hope this clear things out!
Kindest regards,
Jarno
TAB: General:
Form name: Opmerkingenformulier
Email the results: Yes
Other fields: Default after installation
TAB: Setup emails:
To: My Email address
Subject: Opmerkingen formulier ST Intranet
From name: ST intranet
From mail: [email]website@cvt-intranet.nl[/email]
TAB: Form Code:
Form HTML:
<h1>Opmerkingen formulier</h1>
<br />
<h2>Patientgegevens</h2>
<br />
<label for="naam">Naam:</label>
<br />
<input type="text" class="contactfield" name="Naam" id="naam" size="40" />
<br />
<br />
<label for="gebdatum">Geboortedatum:</label>
<br />
<input type="text" class="contactfield" name="Gebdatum" id="gebdatum" size="40" />
<br />
<br />
<label for="ter">Formulier is ter:</label>
<br />
<select size="1" name="Ter" id="ter" class="contactfield" >
<option value="Informatie">Informatie</option>
<option value="AfwachtingAntwoord">Afwachting Antwoord</option>
</select>
<br />
<br />
<br />
<input name="formulierverzenden" type="submit" value="Verzenden" class="contactbutton"/>
<br />
<br />
On Submit code - before sending email:
(PHP code with tags)
<?php
$Ter =& JRequest::getString('Ter', 'AfwachtingAntwoord', 'post');
if ( $Ter == 'AfwachtingAntwoord' ) {
$email->enabled = '1';
}
?>
TAB DB Connection:
Enable data storage: Yes
Database to store is selected
Autogenerated code:
Save data/email order: After email
Autogenerated:
<?php
if($paramsvalues->dbconnection == "Yes"){
$user = JFactory::getUser();
$row =& JTable::getInstance("opmerkingenformulier", "Table");
srand((double)microtime()*10000);
$inum = "I" . substr(base64_encode(md5(rand())), 0, 16);
JRequest::setVar( "recordtime", JRequest::getVar( "recordtime", date("Y-m-d")." - ".date("H:i:s"), "post", "string", "" ));
JRequest::setVar( "ipaddress", JRequest::getVar( "ipaddress", $_SERVER["REMOTE_ADDR"], "post", "string", "" ));
JRequest::setVar( "uid", JRequest::getVar( "uid", $inum, "post", "string", "" ));
JRequest::setVar( "cf_user_id", JRequest::getVar( "cf_user_id", $user->id, "post", "int", "" ));
$post = JRequest::get( "post" , JREQUEST_ALLOWRAW );
if (!$row->bind( $post )) {
JError::raiseWarning(100, $row->getError());
}
if (!$row->store()) {
JError::raiseWarning(100, $row->getError());
}
global $row_opmerkingenformulier;
$row_opmerkingenformulier = $row;
}
?>
All the other fields ar default as they where after the installation of Chronoforms.
Hope this clear things out!
Kindest regards,
Jarno
Hi mrbaselier,
I've taken another look at the code and there is no good way of doing this without hacking chronocontact.php :-(
To do the hack find this around line 490
Bob
I've taken another look at the code and there is no good way of doing this without hacking chronocontact.php :-(
To do the hack find this around line 490
/**
* Send the email(s)
*/
$email_sent = JUtility::sendMail($from, $fromname, $recipients, $subject, $email_body, $mode, $ccemails, $bccemails, $attachments, $replyto_email, $replyto_name );
if ( $debug ) {
and replace with this /**
* Send the email(s)
*/
if ( $email->enabled == "1" ) {
$email_sent = JUtility::sendMail($from, $fromname, $recipients, $subject, $email_body, $mode, $ccemails, $bccemails, $attachments, $replyto_email, $replyto_name );
}
if ( $debug ) {
and then have your form html set $email->enabled to 'false' or '0'Bob
Hello Bob,
Thank you so much for helping me out.
I applied the hack to the chronoforms.php.
Than I changed this in my:
On Submit code - before sending email:
To:
Sadly this still not works. Am I doing something wrong here?
Kindest regards,
Jarno
Thank you so much for helping me out.
I applied the hack to the chronoforms.php.
Than I changed this in my:
On Submit code - before sending email:
<?php
$Ter =& JRequest::getString('Ter', 'AfwachtingAntwoord', 'post');
if ( $Ter == 'AfwachtingAntwoord' ) {
$email->enabled = '1';
}
?>
To:
<?php
$Ter =& JRequest::getString('Ter', 'AfwachtingAntwoord', 'post');
if ( $Ter == 'AfwachtingAntwoord' ) {
$email->enabled = 'false';
}
?>
Sadly this still not works. Am I doing something wrong here?
Kindest regards,
Jarno
Hi mrbaselier,
We may be checking for the wrong thing here, try this version. It should stop the email being sent if Ter = Informatie
Bob
We may be checking for the wrong thing here, try this version. It should stop the email being sent if Ter = Informatie
<?php
$Ter =& JRequest::getString('Ter', '', 'post');
if ( $Ter == 'Informatie' ) {
$email->enabled = 'false';
}
?>
Bob
Hi,
Sorry, but it should be
Regards,
Max
Sorry, but it should be
$emails[0]->enabled = '1';
but not $email->enabled = '1';
as I posted yesterday, no hack is needed, this should work and is tested many times!😉Regards,
Max
Hello Bob and Max,
I tried the sugested solutions with and withoud the hacked chronocontact.php but still no solution. I have realy no idea what I am doing wrong here. The switch field is:
and the On Submit code - before sending email code is:
Sadly still no luck! Hope you see what I am doing wrong here....
Is it maybe the use of capitals in "AfwachtingAntwoord" or in "Ter"???
Kindest regards,
Jarno
I tried the sugested solutions with and withoud the hacked chronocontact.php but still no solution. I have realy no idea what I am doing wrong here. The switch field is:
<label for="ter">Formulier is ter:</label>
<br />
<select size="1" name="Ter" id="ter" class="contactfield" >
<option value="Informatie">Informatie</option>
<option value="AfwachtingAntwoord">Afwachting Antwoord</option>
</select>
and the On Submit code - before sending email code is:
<?php
$Ter =& JRequest::getString('Ter', 'AfwachtingAntwoord', 'post');
if ( $Ter == 'AfwachtingAntwoord' ) {
$emails[0]->enabled = '1';
}
?>
Sadly still no luck! Hope you see what I am doing wrong here....
Is it maybe the use of capitals in "AfwachtingAntwoord" or in "Ter"???
Kindest regards,
Jarno
Hi Jarno,
try this code with no hacks:
Assuming you have at least 1 email and its configured properly and it emails fine without any PHP code! and that the code above is in the "onsubmit before email" box!
Cheers
Max
try this code with no hacks:
<?php
$Ter =& JRequest::getVar('Ter');
if ( $Ter == 'AfwachtingAntwoord' ) {
$emails[0]->enabled = '1';
}
?>
Assuming you have at least 1 email and its configured properly and it emails fine without any PHP code! and that the code above is in the "onsubmit before email" box!
Cheers
Max
Dear Max,
I wish to tell you that it works, but sadly it doesn't.
I have no idea where it goes wrong.
Thank you for your great support and I hope you can come up with another solution.
I am willing to give you the logon credentials of my Joomla website so you can take a look yourself.
Kindest regards,
Jarno
I wish to tell you that it works, but sadly it doesn't.
I have no idea where it goes wrong.
Thank you for your great support and I hope you can come up with another solution.
I am willing to give you the logon credentials of my Joomla website so you can take a look yourself.
Kindest regards,
Jarno
Hi Jarno,
Sorry, please try it with :
let me know!
Max
Sorry, please try it with :
$Ter = JRequest::getVar('Ter');
instead of $Ter =& JRequest::getVar('Ter');
let me know!
Max
Sorrie Max....still no luck with this one....
Well, I think we forgot an important thing, the switch "enables" the email in the correct case, so it should be disabled by default, do you have it already enabled in the email properties ?
Max
Max
YESSSS this works like a charm.
I had my mail enabled by default. After disabling it it works GREAT!!!
Thank you for your wonderfull and continious support!!!
Kindest regards,
Jarno
I had my mail enabled by default. After disabling it it works GREAT!!!
Thank you for your wonderfull and continious support!!!
Kindest regards,
Jarno
No problems, glad we found it on time!😀
Regards,
Max
Regards,
Max
Im not sure if this is the correct topic im in, anyway when i send the form im getting the filled out fields and the empty ones i would like only the fields that were chosen to be on the email...
is this possible?
thanks,
john
is this possible?
thanks,
john
Hi John,
Techincally you can do it. You just need to add PHP to your email template to check each field and only out put those that you want.
Bob
PS To use PHP in the Email template you will need to turn off 'Use HTML Editor' in the Email Setup properties.
Techincally you can do it. You just need to add PHP to your email template to check each field and only out put those that you want.
Bob
PS To use PHP in the Email template you will need to turn off 'Use HTML Editor' in the Email Setup properties.
ok greyhead,
I seem ready to tackle this a bit.. where do i start ?
In order for me to see the data i have specified in email templates all fields to BOLD and colors. bt its still messy.
i suppose it will be a if fields ="" don't echo or something like that.. i have about 80 fields depending on what user selects.
what im hoping is if that user selects option1 he doesnt need to see the other parts of the form.. just whats necessary and emailed those parts of the form, it would be alot smarter and a smaller form because right now its to big...imagine 70 fields + in your face..
let know please.
thanks
John
I seem ready to tackle this a bit.. where do i start ?
In order for me to see the data i have specified in email templates all fields to BOLD and colors. bt its still messy.
i suppose it will be a if fields ="" don't echo or something like that.. i have about 80 fields depending on what user selects.
what im hoping is if that user selects option1 he doesnt need to see the other parts of the form.. just whats necessary and emailed those parts of the form, it would be alot smarter and a smaller form because right now its to big...imagine 70 fields + in your face..
let know please.
thanks
John
Hi jnba,
You'll need to turn off the HTML template editor in the Email setup so that you can use the plain text editor to let you add PHP.
In the editor you'll see for example
Bob
You'll need to turn off the HTML template editor in the Email setup so that you can use the plain text editor to let you add PHP.
In the editor you'll see for example
<div class="form_item">
<div class="form_element cf_textbox"><label class="cf_label" style="width: 150px;">Name</label> <span>{text_0}</span></div>
<div class="cfclear"></div>
</div>
<div class="form_item">
<div class="form_element cf_textbox"><label class="cf_label" style="width: 150px;">Email</label> <span>{text_1}</span></div>
<div class="cfclear"></div>
</div>
<div class="form_item">
<div class="form_element cf_button"></div>
<div class="cfclear"></div>
</div>
Inside this you can see that each from element has it's own form element like this<div class="form_item">
<div class="form_element cf_textbox"><label class="cf_label" style="width: 150px;">Email</label> <span>{text_1}</span></div>
<div class="cfclear"></div>
</div>
You are going to need to wrap each of these blocks in a little PHP<?php
if ( {text_1} ) {
?>
<div class="form_item">
<div class="form_element cf_textbox"><label class="cf_label" style="width: 150px;">Email</label> <span>{text_1}</span></div>
<div class="cfclear"></div>
</div>
<?php
}
?>
I'm not absolutely certain that if ( {text_1} ) { will work correctly, if it doesn't then you'd need if ( JRequest::getVar('text_1') ) { instead. Bob
This topic is locked and no more replies can be posted.