Forums

Include multiple fields in dynamic subject e-mail

Brick1881 13 Apr, 2011
Hi,
Joomla 1.6.1, ChronoForms v4.0 1.7RC

I want to get some additional fields added to the dynamic subject e-mail field in order to get Google Calendar to add the event information that the user inputs in the form.
I am thinking of using http://www.myeventbot.com/ in order to do this. (anyone know a better way to do this?)

Therefore I need a Subject looking like: [whattextfield datetime_field1 "to" datetime_field2].

I have tried numerous variations of the php-code I found on this forum. I am adding this to The "Custom Code - Before Email(s)".

<?php
// Include different input data in dynamic subject
$name = JRequest::getString('navn', '', 'post') . ' ' . JRequest::getString('startdato', '', 'post') . ' ' . JRequest::getString('sluttdato', '', 'post');
$subject = "[$name]";
JRequest::setVar('subject', $subject);
?>


The field names are as follows = and in english
navn = name
startdato = start date/time
sluttdato = end date/time

This is the latest code I used, but I have tested different variations found on the forum without anything happening. I receive an e-mail to the dynamically set e-mail address (via hidden field) but the subject is always empty. In the "Dynamic subject field" i input: subject.

I have no knowledge of php and I am using an outofthebox installation of the forum. Form created with wizard.
To me it seems at the code-window is not activated or something. Nothing happens at all!
GreyHead 13 Apr, 2011
Hi brick1881,

The data structure has changed in CFv4. It no longer reads the $_POST array for dynamic values but instead transfers all the values into a $form->data array so you need to add the values there.

Please try replacing
JRequest::setVar('subject', $subject);
with
$form->data['subject'] = $subject;
Hopefully that will do the trick.

Bob
Brick1881 13 Apr, 2011
Yes, that took care of it. I'm posting the whole code here for other newbies like me that like to copy/paste.
name, startdate, enddate = Field names
anytext = put in text or space between the field name values. Also possible to input text in front of first JRequest by adding
'xxx '.
i think.
subject = put this in your dynamic subject in e-mail configuration.

<?php
// Include different input data in dynamic subject
$name = JRequest::getString('name', '', 'post') . ' anytext ' . JRequest::getString('startdate', '', 'post') . ' anytext ' . JRequest::getString('enddate', '', 'post');
$subject = "[$name]";
$form->data['subject'] = $subject;
?>


Thanks a lot for your help so far!
lundmark 20 Jun, 2011

The data structure has changed in CFv4. It no longer reads the $_POST array for dynamic values but instead transfers all the values into a $form->data array so you need to add the values there.



Thank you Brick for posting this for others.

Tried numerous ways but did not have any luck. I did use values relevant to my form. I am unsure where to place this code in chronoforms. Does it go in with the form code, or in the "extra code"? Also, do I need to have "subject" as a hidden field in my form, if I do will the subject record to the database (not desired just curious)?

Thanks again.
Max_admin 20 Jun, 2011
Hi lundmark,

This is for V4, you mention the "extra code" ? there is no extra code boxes in V4, please double check ?

Regards,
Max
Max
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
This topic is locked and no more replies can be posted.