Replace num with title in email placeholder

5 posts by 2 authors in: Forums > CMS Builder
Last Post: February 26, 2023   (RSS)

By JeffC - February 22, 2023

Hi

My booking form has a pulldown list field called 'reason'.

The 'reasons' are stored in tablename: reason
Use this field for option values: num
use this field for option labels: title

My placeholder uses the num in the email. How do I alter this so the title is sent.

Thanks in advance

This is what I have so far.

	// SendEmail
	$emailHeaders = emailTemplate_loadFromDB(array(
	'template_id'  => 'Booking Enquiry',
	'placeholders' => array(
	'reason'       => (is_array($_REQUEST['reason']))? implode(",", $_REQUEST['reason']): $_REQUEST['reason'] ,
	),
	));
Jeff

By JeffC - February 25, 2023

Thanks Dave

The code block works – when I uncomment the code I get the titles for each of the records – but how to I get output to send in my email?

Is it as simple as changing:

'reason' => (is_array($_REQUEST['reason']))? implode(",", $_REQUEST['reason']): $_REQUEST['reason'] ,

to

'reason' => $reasonTitles,
Jeff

By JeffC - February 25, 2023

Sorry Dave,

I've answered my own question. Probably should have done that before posting :)

'reason' => $reasonTitles,

Seems to do the trick. Unless you think there is a reason to not do it this way?

Jeff

By Dave - February 26, 2023

Yea, that's perfect!

When possible we like to make the code as readable and simple as possible as it makes future maintenance easier.

Dave Edis - Senior Developer
interactivetools.com