Edit subject in mail sent from form

Permalink 1 user found helpful
How can I edit the text in mail subject sent from a concrete form?

View Replies: View Best Answer
chunksmurray replied on at Permalink Reply
chunksmurray
If you are comfortable with editing php, then you can go into the Form blocks controller.php and change subject line there.

Probably best to copy the form block folder from /concrete/blocks to /blocks first before changing anything.

Not sure if there is an easier way?
rthil replied on at Permalink Reply
I cant find it. Can you tell me the exact line number in concrete/blocks/form/controller.php?
chunksmurray replied on at Permalink Reply
chunksmurray
Line 311.

$mh->setSubject($this->surveyName.' '.t('Form Submission') );
rthil replied on at Permalink Reply
thank you, line 327 in my controller.php
AVL replied on at Permalink Reply
AVL
Hi, does anyone know where could I find this code in version 5.6.1.2?

concrete/blocks/form/controller.php now only has the following:

<?php  
defined('C5_EXECUTE') or die("Access Denied.");
class FormBlockController extends Concrete5_Controller_Block_Form {}
class FormBlockStatistics extends Concrete5_Controller_Block_FormStatistics {}
class MiniSurvey extends Concrete5_Controller_Block_FormMinisurvey {}
HOBOcs replied on at Permalink Reply
HOBOcs
I'm looking for the same thing in 5.6.1.2 as well... if you find it please post.
Thanks
mhawke replied on at Permalink Best Answer Reply 1 Attachment
mhawke
A couple of versions ago, the 'real' controllers were moved to [root]/concrete/core/controllers. The benefit of this is that you can now just override a single function rather than having to override the entire class. To override the form controller and change the 'Subject' text, take the attached file and rename it back to controller.php and put it in

[root]/blocks/form/controller.php

If you have a look in this file, you will see that it just contains the 'action_submit_form()' function and on line 216 you will see that I have added 'Test submission' to the subject.

Give it a whirl.
AVL replied on at Permalink Reply
AVL
Hi - thanks so much for answering!

If I want our subject line to just read "AVL Answers" - do I change everything between the quotes, or just where it reads Test Form Submission --

$mh->setSubject(t('%s Test Form Submission', $this->surveyName));


to

$mh->setSubject(t('AVL Answers', $this->surveyName));


or

$mh->setSubject(t('%s AVL Answers', $this->surveyName));


Sorry - I'm not exactly familiar with how the %s works - but if I delete it, I have to also delete something else that corresponds to it, right?
mhawke replied on at Permalink Reply
mhawke
%s is the name of the form so I wouldn't remove it or else every form on your site will have the same subject and you won't be able to tell which form is being returned. That's why the core 'subject' is so plain. It's trying to add a generic 'predicate' to the Subject line when it doesn't know the 'subject' of the sentence yet.

If the form called 'Contact' is being submitted, then the Subject will be 'Contact Form Submission'. If the form called 'AVL Answers' is being submitted, the Subject will be 'AVL Answers Form Submission'

If you look at the code, this line tells you how it works:

$mh->setSubject(t('%s Form Submission', $this->surveyName));


The %s is a placeholder and the value of $this->surveyName gets injected in place of the %s

Make sense?
AVL replied on at Permalink Reply
AVL
Ah, ok - That's about how I thought it worked. I'll have to think about the form names...

We only have one main form - the generic contact us form... I have a couple other forms that almost never get used, but they would be extremely easy to tell what form they are.

I'll have to think about how to go about this - what to name my forms and what to have as a global add-on to the form name. Thanks so much for your help!
HOBOcs replied on at Permalink Reply
HOBOcs
Thanks mhawke - this helped me a bunch as well.

In Forms - I'm also changing the Subject on the "guestbook.php"

The only other thing I'm looking for is where do I change the Reply to Email from "Concrete5-noreply" to something like "Mywebiste-noreply"
JonRimmer replied on at Permalink Reply
Hi There
Is there any way of getting the name of the form user to appear in the subject title. Client of mine want it so she can quickly see who sent form.

many thanks for your help