CoreCommunity ExtensionsIncubatorDistributionsTYPO3 4.5 ProjectsTYPO3 4.6 ProjectsTYPO3 4.7 ProjectsTYPO3 6.0 ProjectsTYPO3 6.1 ProjectsTYPO3 6.2 Projects (+)

Bug #4219

Array value in Email template by use of multiple checkbox selection

Added by Frank Mueller almost 4 years ago. Updated over 2 years ago.

Status:Closed Start date:2009-08-10
Priority:Should have Due date:
Assignee:Reinhard Führicht % Done:

100%

Category:Finisher
Target version:-
Votes: 0

Description

If you use multiple checkbox selection in a form
the Email template prints out an Array value instead of the multiple values separates by ",".

Is there a different procedure for the markers???
I use ###formhandler[XXX][]### in the form template and ###value_XXX### or ###XXX### in the Email template.

Associated revisions

Revision 23307
Added by Reinhard Führicht almost 4 years ago

Finally fixed issue #4219.
###value_[fieldname]### markers didn't work with arrays in email templates

Revision 23307
Added by Reinhard Führicht almost 4 years ago

Finally fixed issue #4219.
###value_[fieldname]### markers didn't work with arrays in email templates

History

Updated by Reinhard Führicht almost 4 years ago

Just tested this using the current SVN trunk.

HTML:

<input type="checkbox" name="contact[check][]" value="A" />A<br />
<input type="checkbox" name="contact[check][]" value="B" />B<br />
<input type="checkbox" name="contact[check][]" value="C" />C<br />

In TEMPLATE_EMAIL_... or TEMPLATE_CONFIRMATION or TEMPLATE_PDF

###value_check###

If all checkboxes are checked, the marker ###value_check### gets replaced with A,B,C.
Works as expected.

Updated by Frank Mueller almost 4 years ago

tested again with current SVN trunk.
It's only working on confirmation template! Not on Email and PDF!

used this in template:

<!-- ###TEMPLATE_FORM1### begin -->
.
.
.
<div class="interests_box">
                <label for="interests_sports">###LLL:interests_sports###</label>
                <input type="checkbox" name="formhandler[Interests][]" id="interests_sports" value="Sports" ###checked_Interests_sports###/>
                <div class="clear"></div>
                <label for="interests_music">###LLL:interests_music###</label>
                <input type="checkbox" name="formhandler[Interests][]" id="interests_music" value="music" ###checked_Interests_music###/>
                <div class="clear"></div>
                <label for="interests_science">###LLL:interests_science###</label>
                <input type="checkbox" name="formhandler[Interests][]" id="interests_science" value="sCIence" ###checked_Interests_science###/>
                <div class="clear"></div>
                <label for="interests_cars">###LLL:interests_cars###</label>
                <input type="checkbox" name="formhandler[Interests][]" id="interests_cars" value="cars" ###checked_Interests_cars###/>
            </div>
            <div class="clear"></div>
.
.
.
<!-- ###TEMPLATE_FORM1### end -->

<!-- ###TEMPLATE_EMAIL_ADMIN_HTML### begin -->
Hello Admin (HTML),
a user has just filled out the form.
###value_Interests###.
<!-- ###TEMPLATE_EMAIL_ADMIN_HTML### end -->

<!-- ###TEMPLATE_CONFIRMATION### begin -->
<table>
  <tr>
    <td>###LLL:interests###</td>
    <td>###value_Interests###</td>
  </tr>
</table>
<!-- ###TEMPLATE_CONFIRMATION### end -->

and this in typo script:
plugin.Tx_Formhandler.settings.predef.singlestep_example {

    # Common configuration
    name = Example SingleStep
    debug = 0
    addErrorAnchors = 1
    templateFile = EXT:formhandler/Examples/SingleStep/template.html
    langFile = EXT:formhandler/Examples/SingleStep/lang.xml
    stylesheetFile = EXT:formhandler/Examples/SingleStep/styles.css
    formValuesPrefix = formhandler

    # HTML wrapping by validation error
    errorListTemplate {
        totalWrap = <ul>|</ul>
        singleWrap = <li class="error">|</li>
    }
    singleErrorTemplate {
        singleWrap = <span class="error">|</span><br />
    }

    # File configuration
    singleFileMarkerTemplate {
        totalWrap = <ul>|</ul>
        singleWrap = <li style="color:maroon;">|</li>
    }
    totalFilesMarkerTemplate {
        totalWrap = <ul>|</ul>
        singleWrap = <li style="color:red;">|</li>
    }
    files {
        clearTempFilesOlderThanHours = 24
        uploadFolder = uploads/formhandler/tmp2/
        enableAjaxFileRemoval = 1
    }
    checkBoxFields = Interests
    # Validators configuration
    validators {
        1 {
            class = Tx_Formhandler_Validator_Default
            config {
                fieldConf {
                    picture {
                        errorCheck.1 = fileAllowedTypes
                        errorCheck.1.allowedTypes = jpg,gif
                        errorCheck.2 = fileMinSize
                        errorCheck.2.minSize = 20000
                        errorCheck.3 = fileMaxSize
                        errorCheck.3.maxSize= 100000
                        errorCheck.4 = fileMaxCount
                        errorCheck.4.maxCount = 2
                    }
                    firstname {
                        errorCheck.1 = required
                        errorCheck.2 = maxLength
                        errorCheck.2.value = 50
                    }
                    lastname {
                        errorCheck.1 = required
                        errorCheck.2 = maxLength
                        errorCheck.2.value = 50
                    }
                    email {
                        errorCheck.1 = required
                        errorCheck.2 = email
                    }
                    Interests {
                        # errorCheck.1 = minItems
                        # errorCheck.1.value = 2
                        errorCheck.2 = required
                    }
                    contact_via {
                        errorCheck.1 = required
                    }
                }
            }
        }
    }

    # Interceptors configuration
    initInterceptors {
        1 {
            class = Tx_Formhandler_Interceptor_RemoveXSS
        }
    }

    # Loggers configuration
    loggers {
        1 {
            class = Tx_Formhandler_Logger_DB
        }
    }

    # Finishers configuration
    finishers {
         1 {
            class = Tx_Formhandler_Finisher_DB
            config {
                table = tt_content
                key = uid
                fields {
                    header {
                        mapping = name
                        if_is_empty = None given
                    }
                    bodytext {
                        mapping = subject
                        seperator = ,
                    }
                    hidden = 1
                    pid = 39
                    subheader.special = sub_datetime
                    crdate.special = sub_tstamp
                    tstamp.special = sub_tstamp
                    imagecaption.special = ip
                }
            }
        }
        2.class = Tx_Formhandler_Finisher_Mail
        2.config {
            limitMailsToUser = 5
            admin {
                to_email = mueller@starxpress.de
                to_name = Some Admin
                subject = SingleStep Request
                sender_email = email
                sender_name = lastname
                replyto_email = email
                replyto_name = lastname
                htmlEmailAsAttachment = 0
                attachment = picture
            }
            user {
                to_email = email
                to_name = lastname
                subject = Your SingleStep request
                sender_email = email@host.com
                sender_name = Some Company
                replyto_email = email@host.com
                replyto_name = TEXT
                replyto_name.value = Some Company
                htmlEmailAsAttachment = 1
                attachment = picture
                attachPDF.class = Tx_Formhandler_Generator_PDF
                attachPDF.exportFields = firstname,lastname,email,Interests,pid,submission_date,ip
             }
        }
        3.class = Tx_Formhandler_Finisher_Confirmation
        3.config {
            returns = 1
            pdf {
                class = Tx_Formhandler_Generator_PDF
                exportFields = firstname,lastname,Interests,pid,ip,submission_date
                export2File = 1
            }
            csv {
                class = Tx_Formhandler_Generator_CSV
                exportFields = firstname,lastname,Interests
            }
        }
    }
}

i changed the Interests to Uppercase for testing!

Updated by Reinhard Führicht almost 4 years ago

  • Status changed from New to Needs Feedback

Yes, you are right!
I am sorry, but I overlooked this when I tested the behaviour.
I added the needed calls to View_Mail and View_Confirmation. View_Form and View_PDF should have worked before.
Please test again and give Feedback, if everything works as expected now.

Updated by Frank Mueller almost 4 years ago

Reinhard Führicht wrote:

Yes, you are right! I am sorry, but I overlooked this when I tested the behaviour. I added the needed calls to View_Mail and View_Confirmation. View_Form and View_PDF should have worked before. Please test again and give Feedback, if everything works as expected now.

still the same behavior!
maybe you should check the fillValueMarkers function in Tx_Formhandler_View_Form !?

    protected function fillValueMarkers() {
        $markers = array();
        if (is_array($this->gp)) {
            foreach($this->gp as $k => $v) {
                if (!ereg('EMAIL_', $k)) {
                    if (is_array($v)) {
                        $v = implode(',', $v);
                    }
                    $v = trim($v);
.
.
.

Updated by Reinhard Führicht almost 4 years ago

The fillValueMarkers() method works fine. I tested it yesterday with a multi step form.
On step 2 I have checkboxes, on step 3 i have a ###value_---### marker for the value of the checkbox array.
This works fine. E-Mail works fine too.
But your HTML looks valid, so I don't really understand why you don't get the right output.

if (is_array($v)) {
    $v = implode(',', $v);
}

These lines of code in fillValueMarkers() check if the value is an Array and if so implode the values using ',' as separator.

Updated by Frank Mueller almost 4 years ago

Reinhard Führicht wrote:

The fillValueMarkers() method works fine. I tested it yesterday with a multi step form. On step 2 I have checkboxes, on step 3 i have a ###value_---### marker for the value of the checkbox array. This works fine. E-Mail works fine too. But your HTML looks valid, so I don't really understand why you don't get the right output.

[...]

These lines of code in fillValueMarkers() check if the value is an Array and if so implode the values using ',' as separator.
only the value in the email doesn't work! in frontend all is working fine!
have you tested like this:

<!-- ###TEMPLATE_EMAIL_ADMIN_HTML### begin -->
Hello Admin (HTML),
a user has just filled out the form.
###value_interests###.
<!-- ###TEMPLATE_EMAIL_ADMIN_HTML### end -->

if i output the value for debugging in the fillValueMarkers function like this (line 857):

} else {
$markers['###value_' . $k . '###'] = Tx_Formhandler_StaticFuncs::reverse_htmlspecialchars($v);
if ($k == "interests") echo "v:".$v;

i get the following output in frontent:
...
Rufe Finisher "Tx_Formhandler_Finisher_Mail" auf!
v:sports,science,cars v:Array E-Mail verschickt an: ...

i think that something overwrites the value with an empty array!

Updated by Reinhard Führicht almost 4 years ago

OK, this was a tricky one.
The problem only occurred when setting html emails and having the TS option checkBinaryCrLf set.
CheckBinaryCrLf option invoked a method containing a bug that ran nl2br() over the whole GP-Array.

I fixed this and my test html emails are fine now. Please give feedback!

Updated by Frank Mueller almost 4 years ago

Reinhard Führicht wrote:

OK, this was a tricky one. The problem only occurred when setting html emails and having the TS option checkBinaryCrLf set. CheckBinaryCrLf option invoked a method containing a bug that ran nl2br() over the whole GP-Array.

I fixed this and my test html emails are fine now. Please give feedback!

Email is working now perfectly!
The PDF template has still the same error!

don't forget your debug output!

thanks!

Updated by Reinhard Führicht almost 4 years ago

Oops, I totally forgot to remove my debug code. Thanks for the hint.

I committed some stuff again.
PDF template should now also work.

Updated by Reinhard Führicht over 3 years ago

I guess this issue can be closed?

Updated by Frank Mueller over 3 years ago

yes you can close

Updated by Reinhard Führicht over 3 years ago

  • Status changed from Needs Feedback to Closed
  • % Done changed from 0 to 100

Also available in: Atom PDF