Forums

Dynamic Subject in Chronoforms 3

danieli 05 Sep, 2008
I have updated my "test bed" Joomla 1.5.6 from Chronoforms 2.5 RC2 to Chronoforms 3.0 Beta2 in order to test the migration of my forms to the new version.

I need to know how to insert text along with the field name for a Dynamic Subject.

For example... Subject: Exit User Form - Employee_Name

"Exit User Form - " is the text part
Employee_Name is the field name

I used to accomplish this in ChronoForm 2.5 with the following code that does not work in 3.0
<?php $_POST['subject'] = "User Exit Form - ".$_POST['Employee_Name'] ?>
danieli 05 Sep, 2008
lol... well, it works like it always did... I was just inventing new functionality it seems...

I was thinking I could get rid of the variable on the form and the On Submit code by piecing a Dynamic Subject together... well ... no... the dynamic subject just accepts the form field name like the good old Special Field Subject in 2.5 did...

I was trying to make the function bigger than it was... no worries๐Ÿ™„

For anyone that doesn't know how to do this, you need only 3 things:
[list=1]
  • a hidden field on your form to store the subject
    <input type="hidden" name="subject" value="">
  • some On Sumbit code to update the form field value
    <?php $_POST['subject'] = "My custom text here ".$_POST['My_Other_Form_Field_Here'] ?>
  • and a Dynamic Subject box in the email setup that uses the form variable.
  • [/list:o]
    shaarp 13 Sep, 2008
    I absolutely love this extension, except for one small thing that is nagging me: All of my forms work with the dynamic fields EXCEPT in the "on submit code" before and after when I want to include a greeting:

    Example:
    <p>{text_2}, thanks for your order!</p>
    <p>Your order has been received and someone from our team will contact you soon.</p>
    <p>We understand that you had a choice in deciding who to do business with. We appreciate you allowing EPIC Sportswear to service you!</p>
    <p>Kind regards,</p>
    <p>Jaime</p>


    I have the dynamic fields working in every other form and part of this extension except here. How do I get {text_2} to return the respective value?

    Cannot deliver website to client until this is corrected. Any help is appreciated!

    Arvin
    bushido 26 Sep, 2008
    Hello,

    Sorry for sounding like a complete noob (which I am), but I am unable to get the dynamic subject working,

    Here are the thing I have done:

    I have a a for with {text_2}, This is the field I want to appear in my email subject line
    I have Subject Dynamic in the email settings.
    I have put <input type="hidden" name="subject" value=""> on the top of my form
    I have put this on the ON SUBMIT box <?php $_POST['subject'] = "My custom text here ".$_POST['text_2'] ?>

    I get the email but no subject filled in. I have V3 Stable, what am I doing wrong.

    Thank you
    GreyHead 26 Sep, 2008
    Hi bushido,

    I think you can just put field_name in the dynamic subject field.

    Bob

    Later: edited to remove unnecessary curly brackets, just use the field name
    bushido 26 Sep, 2008
    I gave that a go a no joy.

    Any other points please.
    Max_admin 26 Sep, 2008
    Hi bushido, please remove this hidden field and the onsubmit code and write text_2 which is the field name in the dynamic subject field, that's all!

    Regards

    Max
    Max, ChronoForms developer
    ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
    ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
    bushido 26 Sep, 2008
    It worked.

    Sorry to be a pain, how would you got about have text and two fields?

    E.g - Application form for "TEXT 1" "TEXT 2"

    Thank you

    PS. Love this tool.๐Ÿ™‚
    Max_admin 27 Sep, 2008
    Hi bushido, this is not possible, only 1 field, unless you want a 3 or 4 lines of code to add at the onsubmit box, let me know if you want to add code and I will show you what to do!

    Regards

    Max
    Max, ChronoForms developer
    ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
    ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
    bushido 27 Sep, 2008
    Please max. It will be good for the other members of the board.

    I have one other question which is concerning SEF. When running my website I have http://www.abc.com/news.html,

    ChronoForms does not do that, in come up with a long string, Is there any way to have it show up as http://www.abc.com/member_application_form.html,

    Tankyou

    P.S, if you want me to start a new thread, just let me know.
    Max_admin 27 Sep, 2008
    Hi bushido, please clarify, how it comes with a long url exactly ? you mean after submit or the form link ?
    Max, ChronoForms developer
    ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
    ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
    bushido 27 Sep, 2008
    This is what I get at present with SEF enabled on J1.5.7 + ChronoForm 3 Stable

    http://231x.co.uk/component/chronocontact/?chronoformname=team_mem_application

    What I would like.

    http://12fx.co.uk/team_mem_application

    Is this possible?

    -----------------------------------------------------------------------------

    I also need this answer please which is a few threads above

    It worked.

    Sorry to be a pain, how would you got about have text and two fields?

    E.g - Application form for "TEXT 1" "TEXT 2"

    Thank you



    Can I get the onSubmit code

    Thank you
    Max_admin 28 Sep, 2008
    Hi,

    #1- make a menu item of type Chronoforms NOT from type URL, thats why it appears like this!
    #2- assuming you have 2 emails there, email number one will be #0 and email number 2 will be #1, so the code will be :

    <?php
    global $mainframe;
    $emails[0]->subject= "Application form for ".JRequest::getVar('text_field_1').' '.JRequest::getVar('text_field_2');
    ?>


    that goes in the onsubmit before email box!

    regards

    Max
    Max, ChronoForms developer
    ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
    ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
    bushido 28 Sep, 2008
    Hi Max

    Going to test out the code tonight.

    Just out of intrest, why would you need two emails?
    bushido 28 Sep, 2008
    Tried it with only one email in place and it seem in work.

    Thank you for the grate support.
    Max_admin 28 Sep, 2008
    Just to clarify in case you had more than 1 email!

    Regards

    Max
    Max, ChronoForms developer
    ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
    ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
    bushido 28 Sep, 2008
    Thank you.

    All working
    Endlessline 07 Oct, 2008
    Max, sorry to beat a dead horse but I'm having a similar problem.

    I have Joomla 1.5.7 and CF 3.0 Stable installed and everything is working perfectly except for putting dynamic elements in the subject

    The name of the form element is 'memb' and it requests the user's membership level (i.e. sponser)

    I put 'memb' (without quotes) in the onSubmit form code area and put 'memb' (no quotes) in the Dynamic subject of the email to be sent out and it worked great.

    I have a problem when I try to do something like "A new request to become a memb has been submitted' (I want to send this to the site administrator). Do I need different syntax when the dynamic field has a string within it as well? Optimally I would like to do "firstName lastName has submitted a request to become a memb" but it looks like that is beyond CF 3.0 at this point?

    I also have to say that you guys have created my favorite component for Joomla and your support has been great with all my other questions. Thanks so much for all you have done
    Max_admin 07 Oct, 2008
    Hi Endlessline,

    As you said, this is not possible with the current V3.0 stable method, you can do it with one line of code at the onsubmit box though :
    
    <?php
    $emails[0]->subject= JRequest::getVar('firstName').' '.JRequest::getVar('lastName').' has submitted a request to become a '.JRequest::getVar('memb');
    ?>


    I assume you have only one email setup!

    Cheers

    Max
    Max, ChronoForms developer
    ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
    ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
    Endlessline 08 Oct, 2008
    Aha, excellent.. and if I have multiple emails? Do I just iterate through the email array?

    Something like... (Assuming I have 5 emails)
    
    <?php
    for($i = 0; $i<4; $i++){
    $emails[$i]->subject= JRequest::getVar('firstName').' '.JRequest::getVar('lastName').' has submitted a request to become a '.JRequest::getVar('memb');
    }
    ?>
    Max_admin 08 Oct, 2008
    yes, great coding!๐Ÿ˜‰
    Max, ChronoForms developer
    ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
    ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
    mus1402 13 Jun, 2011

    #2- assuming you have 2 emails there, email number one will be #0 and email number 2 will be #1, so the code will be :

    <?php
    global $mainframe;
    $emails[0]->subject= "Application form for ".JRequest::getVar('text_field_1').' '.JRequest::getVar('text_field_2');
    ?>


    that goes in the onsubmit before email box!

    regards

    Max



    Hi Max, if I use your method quoted above, what should I enter in 'Dynamic Subject' field under 'Setup Emails' tab ? I tried enter 'subject' nothing seems to appear. what did I do wrong?

    Please help.

    Thanks
    GreyHead 13 Jun, 2011
    Hi mus1402 ,

    This is a very old thread, there are much more recent posts about setting up Dynamic Subjects.

    If you use this method (and the code may no longer work) then you should leave he Dynamic Subject box empty and put a a dummy entry like 'subject' in the standard Subject box (this value will be over-written so isn't important).

    Bob
    mus1402 14 Jun, 2011

    Tried it with only one email in place and it seem in work.

    Thank you for the grate support.



    How did you managed to get this work? What did you put in the 'Dynamic Subject' field?
    This topic is locked and no more replies can be posted.