Hi
In the version 3 for sending email according to a select list I was using this code in the "before sending email" box (it's a who do you want to contact form) :
But I don't know how to do it with the V4, I searched in the forum but nothing, and nothing in the FAQ too.
Thanks for your help !
In the version 3 for sending email according to a select list I was using this code in the "before sending email" box (it's a who do you want to contact form) :
<?php
$recipient = JRequest::getString('select_10', '', 'post');
$emails = array (
'Select1' => 'Email1@Email.com',
'Select2' => 'Email2@Email.com',
'Select3' => 'Email3@Email.com',
);
$email_to_use = $emails[$recipient];
JRequest::setVar('email_to_use', $email_to_use);
?>
But I don't know how to do it with the V4, I searched in the forum but nothing, and nothing in the FAQ too.
Thanks for your help !
Hi mushr00m,
In CFv4 this line
Bob
In CFv4 this line
JRequest::setVar('email_to_use', $email_to_use);
becomes$form->data['email_to_use'] = $email_to_use;
Bob
Thank you GreyHead ! Always on duty ;-)
Just a little question, where do we need to put the code ? because in the V4 there is no "before sending email" box.
Just a little question, where do we need to put the code ? because in the V4 there is no "before sending email" box.
Hi Mushr00m,
Drag in a Custom Code action and move it before the Email action. That's in the Advanced Wizard, I think there's one built into the Eazy Wizard.
Bob
Drag in a Custom Code action and move it before the Email action. That's in the Advanced Wizard, I think there's one built into the Eazy Wizard.
Bob
Hi,
I tried it and it's not working for one part, I don't receive the Email, maybe I did something wrong, I had the custom code before the Email sending, but maybe it's because it putted email_to_use in the dynamic to of the sending email block. Is that right ?
Thanks
I tried it and it's not working for one part, I don't receive the Email, maybe I did something wrong, I had the custom code before the Email sending, but maybe it's because it putted email_to_use in the dynamic to of the sending email block. Is that right ?
Thanks
Hi Mushr00m,
That's correct.
Please add a Debugger action to the On Submit event and see what that shows.
Bob
That's correct.
Please add a Debugger action to the On Submit event and see what that shows.
Bob
Here is the output :
Data Array:
Array
(
[input_text_0] => Test
[input_text_1] => Test@Test.com
[input_text_2] => 00000
[input_select_10] => Oui je cherche un terrain
[input_text_7] => Test
[input_text_3] => Test
[input_select_8] => Montpellier
[input_textarea_4] => Test
[input_submit_5] => Envoyer la demande
[11cf1aabf345f49e00a20fead734c684] => 1
[view] => featured
[option] => com_content
[Itemid] => 101
[chronoform] => DevisForm
[event] => submit
[chronoform_data] => Array
(
[cf_uid] => 1286556e6a8f4dddf85d9ceed7db0987
[cf_created] => 2011-11-08 13:52:18
[cf_ipaddress] => ::1
[cf_user_id] => 0
[input_text_0] => Test
[input_text_1] => Test@Test.com
[input_text_2] => 00000
[input_select_10] => Oui je cherche un terrain
[input_text_7] => Test
[input_text_3] => Test
[input_select_8] => Montpellier
[input_textarea_4] => Test
[input_submit_5] => Envoyer la demande
[11cf1aabf345f49e00a20fead734c684] => 1
[view] => featured
[option] => com_content
[Itemid] => 101
[chronoform] => DevisForm
[event] => submit
[cf_id] => 5
)
[chronoform_data_cf_id] => 5
)
Debug Data
An email has been SENT successfully from (Test)Test@Test.com to
Email template: "here is my email template"
Hi Mushr00m,
You can see that the To address in the Email is empty. So what do you have in the Custom Code?
Bob
You can see that the To address in the Email is empty. So what do you have in the Custom Code?
Bob
See the attached screenshot
Thanks
Ps : I tried deleting the coma after the last email adress but still not working
Thanks
Ps : I tried deleting the coma after the last email adress but still not working
Hi Mushroom,
Is there a 'select_8' input in your form? There is an 'input_select_8'.
Bob
Is there a 'select_8' input in your form? There is an 'input_select_8'.
Bob
No it was an error but even after I changed it's not working. (just to know must it be a coma at the end of the last email adresse like in my screenshot or not ?).
Hi Mushr00m,
There's no comma required there (but it shouldn't break the code).
Bob
There's no comma required there (but it shouldn't break the code).
Bob
Hi Mushr00m,
I'm not sure, add some debug code to see exactly what is happening.
Personally I wouldn't use the On Success event of the ServerSide Validation action. Instead put the other actions after the ServerSide Validation action.
Bob
I'm not sure, add some debug code to see exactly what is happening.
Personally I wouldn't use the On Success event of the ServerSide Validation action. Instead put the other actions after the ServerSide Validation action.
Bob
I Don't understand, if I put the actions after the "server side validation" and not in the "on succes", the serverside validation is useless ? I use it to be sure that the field are correctly filled, so if someone disable the JS I still have a verification.
So if I do what you say, it will just do the serverside validation and after (even if it's failling the serverside test) do the rest...
I don't know if I explained it well, but the main thing is that the Mail, DB and other actions must be read just if the serverside verification is ok, so I will be "more" sure that the field are correctly filled.
Do you think it is the "bad way" to do so ?
So if I do what you say, it will just do the serverside validation and after (even if it's failling the serverside test) do the rest...
I don't know if I explained it well, but the main thing is that the Mail, DB and other actions must be read just if the serverside verification is ok, so I will be "more" sure that the field are correctly filled.
Do you think it is the "bad way" to do so ?
Are you sure about this line of code :
Bob
Hi mushr00m,
In CFv4 this line
JRequest::setVar('email_to_use', $email_to_use);
becomes$form->data['email_to_use'] = $email_to_use;
Bob
So I found out that I had 2 errors, the first one was the last coma that disturb the code and the second one was that I use simple quote in the custom code for the Email adresses and input values, but one of the input value already used one, so dumb me it was normal that it stop !!!
I just changed all the simple quote by double quote. But strange thing is that one an other website I use the exact same code (with this errors) but it works perfectly... Maybe because it is on V3...
Thanks again for your time GreyHead !
I just changed all the simple quote by double quote. But strange thing is that one an other website I use the exact same code (with this errors) but it works perfectly... Maybe because it is on V3...
Thanks again for your time GreyHead !
Hi Mushr00m,
Glad you got it fixed :-) Quotes can be a problem :-(
Just to comment on this from an earlier post:
Actions are run in the orde tha tthey appear in the Event. If one action e.g. Serverside validation completes then the next one will run *unless* the first action redirects or stops the user. Redirection will come from the Redirect User, Show Stopper or Event Loop actions. Pretty much any other action in will let the flow of actions continue.
So for most actions there is no difference between using the On Success Event and putting the following events in sequence in the On Submit event. And it's much easier to follow the workflow if you put them in sequence rather than nesting them one inside the other.
Bob
Glad you got it fixed :-) Quotes can be a problem :-(
Just to comment on this from an earlier post:
I Don't understand, if I put the actions after the "server side validation" and not in the "on succes", the serverside validation is useless ? I use it to be sure that the field are correctly filled, so if someone disable the JS I still have a verification.
Actions are run in the orde tha tthey appear in the Event. If one action e.g. Serverside validation completes then the next one will run *unless* the first action redirects or stops the user. Redirection will come from the Redirect User, Show Stopper or Event Loop actions. Pretty much any other action in will let the flow of actions continue.
So for most actions there is no difference between using the On Success Event and putting the following events in sequence in the On Submit event. And it's much easier to follow the workflow if you put them in sequence rather than nesting them one inside the other.
Bob
So in your opinion I should put :
- Serverside validation
- DB
- Mail
- Thanks message
And put on the onfail of the serverside validation a stopper to stop the flow ?
- Serverside validation
- DB
- Thanks message
And put on the onfail of the serverside validation a stopper to stop the flow ?
Hi mushr00m,
Yes except use an Event Loop to redisplay the form, not a Show Stopper.
Bob
Yes except use an Event Loop to redisplay the form, not a Show Stopper.
Bob
I found out an other error, if I have multiple adresses for one select option like :
I have an error :
Any Idea ?
"OptionSelect" => "toto@toto.com,mister@toto.com",
I have an error :
Language string failed to load: invalid_address: toto@toto.com,mister@toto.com
Any Idea ?
Hi Mushr00m ,
I think that they have to be in an array rather than a string. There is another recent thread talking about this.
Bob
I think that they have to be in an array rather than a string. There is another recent thread talking about this.
Bob
I can't find the thread about that, but it's strange to have something like that :
Is that it ?
$emails = array (
'Select1' => array ('Email1@Email.com','Email1@Email.com'),
'Select2' => 'Email2@Email.com',
'Select3' => 'Email3@Email.com',
);
Is that it ?
I tried it and get : Language string failed to load: invalid_address: Array
So after a lot of test I watched the code for the Dynamic to Email and it's not the same way to handle it than the V3, it use explode to separate the different adresses in the field "dynamic to" and the problem is that I give it the var email_to_use that contain my different Email adresses, so it's not the good way for it...
Do you have any idea to save my life GH ?
Thanks
PS: I tried you Email[GH] but it's the same issue
Do you have any idea to save my life GH ?
Thanks
PS: I tried you Email[GH] but it's the same issue
Hi Mushr00m,
I ran some tests and found a method that works. If you put this in the Custom Code
Bob
For reference:
[list=a]In the Static To box you can use a single email address e.g. user@example.com or a comma separated list of addresses e.g. user_1@example.com, [email]user_2@example.com[/email]
In the Dynamic To box you can use a single input name e.g. email_to or a comma separated list of input names e.g. email_to_1,email_to_2. Each input name must return a single email address.
You can use both the Static TO and Dynamic To boxes at the same time. [/list:o]
I ran some tests and found a method that works. If you put this in the Custom Code
<?php
$form->data['email_to_1'] = 'info+1@greyhead.net';
$form->data['email_to_2'] = 'info+2@greyhead.net';
?>
Then you can use email_to_1,email_to_2 in the Dynamic To box.Bob
For reference:
[list=a]
Yes I tried that already but it's not good for my problem because I have 5 "select" but only two have 2 adresses and all the other one just 1 adress. So I can't use your system, how yould you do with this :
It's an example, all the adresses doesn't have the same end.
<?php
$recipient = JRequest::getString('input_select_8', '', 'post');
$emails = array (
"Select1" => "adress1@gmail.com,adress2@gmail.com",
"Select2" => "adress3@gmail.com,adress4@gmail.com",
"Select3" => "adress5@gmail.com",
"Select4" => "adress6@gmail.com",
"Select5" => "adress7@gmail.com"
);
$email_to_use = $emails[$recipient];
$form->data['email_to_use'] = $email_to_use;
?>
It's an example, all the adresses doesn't have the same end.
Hi Mushr00m,
OK - I understand.
Here's an updated version of the Email [GH] action that I hope will help. Putting {input_name} in the To box should now accept either comma separated strings of email addresses or an array of addresses. Also empty values will be ignored.
So all of these should work OK:
Bob
PS The download version from greyhead.net has also been updated.
OK - I understand.
Here's an updated version of the Email [GH] action that I hope will help. Putting {input_name} in the To box should now accept either comma separated strings of email addresses or an array of addresses. Also empty values will be ignored.
So all of these should work OK:
$form->data[email_to] = '';
$form->data[email_to] = 'user@example.com';
$form->data[email_to] = 'user@example.com, user2@example.com';
$form->data[email_to] = array('user@example.com', user2@example.com');
Bob
PS The download version from greyhead.net has also been updated.
Hi again,
It works but I still have this error with the debug mode :
It works but I still have this error with the debug mode :
Language string failed to load: invalid_address: Language string failed to load: invalid_address: Data Array:
It's such a pain to figure out a so simple thing of the V3, they must make a quick update for that !
Anyway, I found a workaround for the moment, not very proud of it but it work :
And not to have an error when email_to_use2 is empty if modified the email.php (line 109) file in form_actions to have :
Do you think it's not too horrible to use ? It was so easy on V3 !!!
Thanks for your help
Anyway, I found a workaround for the moment, not very proud of it but it work :
<?php
$recipient = JRequest::getString('input_select_8', '', 'post');
$emails1 = array (
"Select1" => "Mail1@gmail.com",
"Select2" => "Mail2@gmail.com",
"Select3" => "Mail3@gmail.com"
);
$emails2 = array (
"Select1" => "Mail4@gmail.com"
);
$form->data['email_to_use1'] = $emails1[$recipient];
$form->data['email_to_use2'] = $emails2[$recipient];
?>
And not to have an error when email_to_use2 is empty if modified the email.php (line 109) file in form_actions to have :
if(isset($form->data[trim($dynamic_recipient)]) AND $form->data[trim($dynamic_recipient)] != "") {.....
Do you think it's not too horrible to use ? It was so easy on V3 !!!
Thanks for your help
This topic is locked and no more replies can be posted.