Send Text not Value

nikola_blin 08 Jun, 2015
Hello.
I didn't find answer in tutorials.

I need to send in letter the TEXT of dropdown selected option. And send the Label TEXT of checkbox.

Example:

<select>
<option value="0">First value</option>
<option value="1" selected>Second value</option>
</select>

In letter I need show "First value" (if it was selected).
nikola_blin 08 Jun, 2015
I tried this in mail template:

<?php
$color_array = array(
  1 => 'green',
  2 => 'blue',
  3 => 'red',
  4 => 'white'
);
$form->data['color_name'] = $color_array[$form->data['color']];
?>


with my data.

After it my On submit action disappear =(

In letter:
Parse error: syntax error, unexpected '4' (T_LNUMBER), expecting ')' in
GreyHead 08 Jun, 2015
1 Likes
Hi nikola_blin,

There may have been a typo in the code you used - it works OK when I test it.

What is the rest of the error you see? The end of the message is helpful.

Bob
nikola_blin 08 Jun, 2015
Are you enter this code in letter template or in form code?
GreyHead 08 Jun, 2015
1 Likes
Hi nikola_blin,

I would add it to a Custom Code action before the Email action then put {color_name} in the Email template.

Bob
nikola_blin 09 Jun, 2015
In custom code I wrote:

<?php
$reg_territory_array = array(
  0 => 'Астана',
  1 => 'Алматы',
  2 => 'Алматинская область',
  3 => 'Южно-Казахстанская область',
  4 => 'Восточно-Казахстанская область',
  5 => 'Костанайская область',
  6 => 'Карагандинская область',
  7 => 'Северо-Казахстанская область',
  8 => 'Акмолинская область',
  9 => 'Павлодарская область',
  10 => 'Жамбылская область',
  11 => 'Актюбинская область',
  12 => 'Западно-Казахстанская область',
  13 => 'Кызылординская область',
  14 => 'Атырауская область',
  15 => 'Мангистауская область'
);
$form->data['reg_territory_custom'] = $reg_territory_array[$form->data['reg_territory']];
?>


and in email template entered {reg_territory_custom}.

Now the error in string
$form->data['reg_territory_custom'] = $reg_territory_array[$form->data['reg_territory']];


"Undefined index: reg_territory"...

Sorry for my "dullness", i'm not good in chronoform action structure =(
GreyHead 09 Jun, 2015
1 Likes
Hi nikola_blin,

Please drag a Debugger action into the On Submit event, then submit the form and post the debug - including the 'dummy emails' results here. Then we can see if reg_territory has a value.

Bob
nikola_blin 09 Jun, 2015
With debugger:

Notice: Undefined index: Reg_territory in /var/www/vhosts/tvoypolis.kz/httpdocs/administrator/components/com_chronoforms5/chronoforms/actions/custom_code/custom_code.php(20) : eval()'d code on line 20 Notice: Undefined index: in /var/www/vhosts/tvoypolis.kz/httpdocs/administrator/components/com_chronoforms5/chronoforms/actions/custom_code/custom_code.php(20) : eval()'d code on line 20
Thank you message (html).
Data Array
Array
(
    [chronoform] => auto_insurance_form_calc_1
    [event] => submit
    [Itemid] => 107
    [option] => com_content
    [view] => article
    [id] => 9
    [reg_territory_custom] => 
    [ip_address] => 92.47.185.235
)
Array
(
)
Errors
Array
(
)
Debug Info
Array
(
    [1] => Array
        (
            [Email] => Array
                (
                    [0] => An email with the details below was sent successfully:
                    [1] => To:info@studio-n.kz
                    [2] => Subject:Новый заказ по программе - ОС ГПО ВТС Стандартное -
                    [3] => From name:Робот веб-сервиса tvoypolis.kz
                    [4] => From email:info@tvoypolis.kz
                    [5] => CC:
                    [6] => BCC:
                    [7] => Reply name:
                    [8] => Reply email:
                    [9] => Attachments:
                    [10] => Array
                        (
                        )

                    [11] => Body:
<table style="font-family: Tahoma; font-size: 13px;" cellpadding="15">
<tr>
<td bgcolor="ececec">
Клиент
</td>
<td bgcolor="f8f8f8">

</td>
</tr>

<tr>
<td bgcolor="ececec">
Контактный телефон
</td>
<td bgcolor="f8f8f8">

</td>
</tr>

<tr>
<td bgcolor="ececec">
Адрес электронной почты
</td>
<td bgcolor="f8f8f8">

</td>
</tr>

<tr>
<td bgcolor="ececec">
Территория регистрации транспортного средства
</td>
<td bgcolor="f8f8f8">

</td>
</tr>

<tr>
<td bgcolor="ececec">
Тип ТС
</td>
<td bgcolor="f8f8f8">

</td>
</tr>

<tr>
<td bgcolor="ececec">
Возраст ТС
</td>
<td bgcolor="f8f8f8">

</td>
</tr>

<tr>
<td bgcolor="ececec">
ИИН
</td>
<td bgcolor="f8f8f8">

</td>
</tr>

<tr>
<td bgcolor="ececec">
Возраст водителя
</td>
<td bgcolor="f8f8f8">

</td>
</tr>

<tr>
<td bgcolor="ececec">
Стаж вождения
</td>
<td bgcolor="f8f8f8">

</td>
</tr>

<tr>
<td bgcolor="ececec">
Является инвалидом
</td>
<td bgcolor="f8f8f8">

</td>
</tr>

<tr>
<td bgcolor="ececec">
Дополнительные водители
</td>
<td bgcolor="f8f8f8">
1. ; ; ;<br/>
2. ; ; ;<br/>
3. ; ; ;<br/>
4. ; ; ;<br/>
5. ; ; ;<br/>
</td>
</tr>

<tr>
<td bgcolor="ececec">
Рассчитанная стоимость полиса
</td>
<td bgcolor="f8f8f8">
 тенге
</td>
</tr>

</table><br /><br />IP: 92.47.185.235
                )

        )

)
GreyHead 09 Jun, 2015
1 Likes
Hi nikola_blin,

There's no reg_territory in the form data?
Data Array
Array
(
    [chronoform] => auto_insurance_form_calc_1
    [event] => submit
    [Itemid] => 107
    [option] => com_content
    [view] => article
    [id] => 9
    [reg_territory_custom] => 
    [ip_address] => 92.47.185.235
)

Bob
nikola_blin 09 Jun, 2015
Hmmm, i am confused.

Let's see:

This is my SELECT block in form code:
<div class="gcore-line-tr gcore-form-row" id="ftr-reg_territory">
	<div class="gcore-line-td" id="ftd-reg_territory">
		<label for="reg_territory" class="gcore-label-top">Территория регистрации транспортного средства</label>
		<div class="gcore-display-table gcore-input-wide" id="fin-reg_territory">
			<select name="reg_territory" id="reg_territory" size="" class=" validate['required']" title="" style="" data-load-state="" data-tooltip="">
				<option value="">Выберите регион</option>
				<option value="0">Астана</option>
				<option value="1">Алматы</option>
				<option value="2">Алматинская область</option>
				<option value="3">Южно-Казахстанская область</option>
				<option value="4">Восточно-Казахстанская область</option>
				<option value="5">Костанайская область</option>
				<option value="6">Карагандинская область</option>
				<option value="7">Северо-Казахстанская область</option>
				<option value="8">Акмолинская область</option>
				<option value="9">Павлодарская область</option>
				<option value="10">Жамбылская область</option>
				<option value="11">Актюбинская область</option>
				<option value="12">Западно-Казахстанская область</option>
				<option value="13">Кызылординская область</option>
				<option value="14">Атырауская область</option>
				<option value="15">Мангистауская область</option>
			</select>
		</div>
	</div>
</div>



Then, this is code in Custom code (Action in "On submit" above all other actions):
<?php
	$reg_territory_array = array(
		0 => 'Астана',
		1 => 'Алматы',
		2 => 'Алматинская область',
		3 => 'Южно-Казахстанская область',
		4 => 'Восточно-Казахстанская область',
		5 => 'Костанайская область',
		6 => 'Карагандинская область',
		7 => 'Северо-Казахстанская область',
		8 => 'Акмолинская область',
		9 => 'Павлодарская область',
		10 => 'Жамбылская область',
		11 => 'Актюбинская область',
		12 => 'Западно-Казахстанская область',
		13 => 'Кызылординская область',
		14 => 'Атырауская область',
		15 => 'Мангистауская область'
	);
	$form->data['reg_territory'] = $reg_territory_array[$form->data['reg_territory']];
?>


Then, in mail template I insert variable
{reg_territory}
.

Is it right?
nikola_blin 10 Jun, 2015
Uhuuu! I found my mistake!

Name option of "reg_territory" written with a capital letter.

Thanks for your time, GreyHead.
This topic is locked and no more replies can be posted.