Forums

Dynamic mail subject, dropdown option name instead of value.

taro8 02 Sep, 2015
Im currently trying to set up dynamic mail subject with uses a dropdown input as part of the info that is put in the subject. unfortunately what is actually put there is the value instead of the option label you can see when filling out forms.

A simple presentation, I have a following option in my form:

lederpington=Very different option

Right now Im getting "lederpington" in the email subject, while I want "Very different option" to appear instead.
taro8 03 Sep, 2015
Almost got it working, but I got this error:


Parse error: syntax error, unexpected '$form' (T_VARIABLE), expecting ')' in C:\xampp\htdocs\codex\administrator\components\com_chronoforms5\chronoforms\actions\custom_code\custom_code.php(20) : eval()'d code on line 12



My PHP for subject generation.

<?php


$przedmiot_array = array(
  mieszkanie => 'Mieszkanie',
  dom => 'Dom',
  dzialka => 'Dom',
  lokal => 'Lokal',
  hala => 'Hala',
  obiekt => 'Obiekt'

$form->data['przedmiot_name'] = $przedmiot_array[$form->data['przedmiot']];

$form->data['subject'] = "Nieruchomość {$form->data['przedmiot_name']}, {$form->data['miasto']}, {$form->data['powierzchnia']}m², {$form->data['cena']} PLN";
?>


I also get an error when I tried using the new "przedmiot name" in an email, as well as having troubles with defining other arrays:

<?php


$wojewodztwo_array = array(
	dolnoslaskie => 'Dolnośląskie',
	kujawsko-pomorskie => 'Kujawsko-pomorskie',
	lubelskie => 'Lubelskie',
	lubuskie => 'Lubuskie',
	lodzkie => 'Łódzkie',
	malopolskie => 'Małopolskie',
	mazowieckie => 'Mazowieckie',
	opolskie => 'Opolskie',
	podkarpackie => 'Podkarpackie',
	podlaskie => 'Podlaskie',
	pomorskie => 'Pomorskie',
	slaskie => 'Śląskie',
	swiętokrzyskie => 'Świętokrzyskie',
	warminsko-mazurskie => 'Warmińsko-mazurskie',
	wielkopolskie => 'Wielkopolskie',
	zachodniopomorskie => 'Zachodniopomorskie'
);

$form->data['wojewodztwo_name'] = $wojewodztwo_array[$form->data['wojewodztwo']];
?>


Notice: Use of undefined constant dolnoslaskie - assumed 'dolnoslaskie' in C:\xampp\htdocs\codex\administrator\components\com_chronoforms5\chronoforms\actions\custom_code\custom_code.php(20) : eval()'d code on line 5



I put that in custom code before email sending step

I got an email, but without a subject, przedmiot_name and wojewodztwo_name. How can I fix this?
GreyHead 03 Sep, 2015
1 Likes
Hi taro8,

Please check your PHP
  hala => 'Hala',
  obiekt => 'Obiekt'
); // << add this line

Bob
taro8 03 Sep, 2015
Answer
'hala' => 'Hala',
  'obiekt' => 'Obiekt'
);


I was also missing apostrophes with generated errors about undefined constant and messed up my wojewodztwo array. with those and the ");" added everything works correctly.

Thanks you for your help!
This topic is locked and no more replies can be posted.