Hello,
I will wish to send mail urls from a checkbox group.
I did some tests with a simple checkbox with this syntax:
Field value: http://www.MyURL.com
message content : <a href="{checkbox1}">{checkbox1}</a>
Result OK (email with active link)
But I have a problem with the checkbox group
I added a Handle Arrays to send multiple options checkbox_group
checkbox_group options:
http://www. MyURL_1.com=My LINK 1
http://www. MyURL_2.com=My LINK 2
If I use this syntax in the message content:
<a href="{checkbox_group1}">{checkbox_group1}</a>
I do not give 2 urls but a single url, and a mixture of MyUrl_1 MyUrl2 ???
<a href="http://www. MyURL_1.com, http://www. MyURL_2.com">http://www. MyURL_1.com, http://www. MyURL_2.com</a>
instead of
<a href="http://www. MyURL_1.com">http://www. MyURL_1.com</a>, <a href="http://www. MyURL_2.com">http://www. MyURL_2.com</a>
If someone has a solution or an idea of the problem?
Best Regards
Thank you
I will wish to send mail urls from a checkbox group.
I did some tests with a simple checkbox with this syntax:
Field value: http://www.MyURL.com
message content : <a href="{checkbox1}">{checkbox1}</a>
Result OK (email with active link)
But I have a problem with the checkbox group
I added a Handle Arrays to send multiple options checkbox_group
checkbox_group options:
http://www. MyURL_1.com=My LINK 1
http://www. MyURL_2.com=My LINK 2
If I use this syntax in the message content:
<a href="{checkbox_group1}">{checkbox_group1}</a>
I do not give 2 urls but a single url, and a mixture of MyUrl_1 MyUrl2 ???
<a href="http://www. MyURL_1.com, http://www. MyURL_2.com">http://www. MyURL_1.com, http://www. MyURL_2.com</a>
instead of
<a href="http://www. MyURL_1.com">http://www. MyURL_1.com</a>, <a href="http://www. MyURL_2.com">http://www. MyURL_2.com</a>
If someone has a solution or an idea of the problem?
Best Regards
Thank you
Hi g128,
ChronoForms isn't clever enough to know that you want to create a series of <a> tags from the form data. You have to give it a helping hand with some Custom Code.
Also I suspect that the http:// in the option values may be causing hiccups.
I suggest that you change your options to be like this.
In the On Submit event add a Custom Code action with code like this:
Bob
ChronoForms isn't clever enough to know that you want to create a series of <a> tags from the form data. You have to give it a helping hand with some Custom Code.
Also I suspect that the http:// in the option values may be causing hiccups.
I suggest that you change your options to be like this.
www.MyURL_1.com=My LINK 1
www.MyURL_2.com=My LINK 2
and make sure that the checkbox group has an array name ending in [] so you get ll the values returned e.g. links[]
In the On Submit event add a Custom Code action with code like this:
<?php
if ( empty($form->data['links']) || !is_array($form->data['links']) ) {
$form->data['link_list'] = '';
return false;
}
$links = array();
foreach ( $form->data['links'] as $l ) {
$links[] = "<a> href='http://{$l}' >{$l}</a>":
}
$form->data['link_list'] = implode("\n", $links);
?>
Then add {link_list} to the Email template.
Bob
Hi Bob,
Your solution works perfectly !
I fixed the code (there was 2 small problems line 8)
I added a <br> for clarity
Thank you very much it helped me to understand a little more running ChronoForms which is very powerful tool.
I get the following results by mail:
www.MyURL_1.com
www.MyURL_2.com
The links are active, perfect, I try now to display the titles of the options instead of the links.
My LINK 1
My LINK 2
Question : When there are several "checkbox group", should multiply Custom code?
NB: I deleted the "Handle Arrays" problematic..
thank you
Your solution works perfectly !
I fixed the code (there was 2 small problems line 8)
$links[] = "<a href='http://{$l}' >{$l}</a>";
I added a <br> for clarity
<?php
if ( empty($form->data['links']) || !is_array($form->data['links']) ) {
$form->data['link_list'] = '';
return false;
}
$links = array();
foreach ( $form->data['links'] as $l ) {
$links[] = "<a href='http://{$l}' >{$l}</a><br>";
}
$form->data['link_list'] = implode("\n", $links);
?>
Thank you very much it helped me to understand a little more running ChronoForms which is very powerful tool.
I get the following results by mail:
www.MyURL_1.com
www.MyURL_2.com
The links are active, perfect, I try now to display the titles of the options instead of the links.
My LINK 1
My LINK 2
Question : When there are several "checkbox group", should multiply Custom code?
NB: I deleted the "Handle Arrays" problematic..
thank you
This topic is locked and no more replies can be posted.