The Dummy Field and The Empty email

nfg 08 Jul, 2009
Hello,

I'm going mad, and I hope you folks can help.
This isn't your standard empty email problem, at least I don't think so. I've been wrong before.

What I've been doing is this:

The form gets filled out.
The form redirect takes you to another form that displays a preview of what you just posted with 'edit' and 'post' buttons.
This form has a hidden dummy field in it that is empty, but it will contain the html formatted version of the form data.
Before the email is sent the field is populated along with all the others using this:
foreach($send_values as $key=>$val){
	
	JRequest::setVar($key, $val);

}

The data is actually carried along in the session, not the post array. The fields in the second form are empty - populated entirely by the code above.

What happens is that the post array is correct, the database is populated correctly, but the email is empty. Is there somewhere else I can set the value so that the email gets the HTML preview?

I have checked and rechecked the name of the field in the email template, the form, and the post array after my modifications. Everything checks out, but the email is still empty.

This is the source of the email as I receive it:


<html>
	<head>
		<title></title>
		<base href="JURI::base()/" />
	</head>
	<body><p><span></span></p><br /><br />Submitted by [ip removed]</body>
</html>
nfg 08 Jul, 2009
Weirdness:

Earlier I said that the post array was correct, and it is - sort of.

My script to prepare content is placed BEFORE the email is sent.
exit(print_r($_POST))

The above at the end of my script shows the post array populated the way I want it.
The debug from chronoforms says that the post array is empty - as if the email was sent before my script could get to it.

Again, The data is written correctly to the DB.
GreyHead 09 Jul, 2009
Hi nfg,

This is all very complicated and I'm not sure what is happening when. I suspect that the database is being updated by form 1 and that there is no data returned in the $_POST array from Form 2.

ChronoForms has a confirmation page plugin that will do most (all) of this for you without the need for a second form I suggest that you scrap the second form and use the plugin instead.

Bob

PS There are some bugs in the released version of the plugin one of which stops the Submit & Back Buttons showing, please unzip the attached fixed version and copy it to your com_chronocontact/plugins folder.[/code]
nfg 09 Jul, 2009

This is all very complicated and I'm not sure what is happening when. I suspect that the database is being updated by form 1 and that there is no data returned in the $_POST array from Form 2.



Thanks Bob,

I'll check out the update. I think I am using an older version: 3.0 Stable. I'd rather not upgrade right now if I don't have to.

I appreciate your idea that all this has in fact already been done. In my version I guess it hasn't, anyway I've written all this stuff and in theory there's no reason why it shouldn't work. In fact, I've had similar things working before where I make modifications and include them in the email. It gives me more control than using the email template, which is good for some things, but not for this.

As for the order of things, I'll try to be more clear.

form1:no DB connection
Data sent in the post array

form2: DB Connection
in a PHP script at the top of the form the data is used to lay out an HTML preview of the post data.
Hidden blank fields are present for CF to read, plus two submit buttons, one called 'edit' one called 'post'
An additional field is included called 'sf_message' which is also empty.
In the script assorted text transformations are done on the data and then it is copied to the session array.
The generated html preview is placed into the session array as 'sf_message' and then echoed to the page.

Before the email is sent:
By this time the post array has been replaced with the empty fields.
This script does the following.
If the user clicked 'edit' we go back to form 1 and use the session data to repopulate the form.
otherwise, some final adjustments are made to the session data and ....
The session data is written in to the post array.

At this point the email template should pick up the post array and select 'sf_message' from it to insert into the email.

The problem is that CF picks up the post array while it is still empty and before my second script can repopulate the post array.

I hope this is more clear, and thanks for any ideas you may have.
nml375 09 Jul, 2009
Hi nfg,
One dirty hack would be to use the serverside validation code box, as this is executed before any other processing is done. Other than that, I could only recommend checking all the run-order settings. Restoring posted data using sessions/JSession usually works like a charm (as long as you stay away from File-inputs).

Or wait, are you using a custom mail-template or are you using CF's default?
You might have to re-enter all the names (and types) of the fields from form1 into the "Form Fields names" and "Form Fields types" under the Auto-Generated Code tab.

/Fredrik
nfg 09 Jul, 2009
Thanks Fredrik for the suggestion.
I'm determined this will work though. It has worked before and it will work again if it kills me.
But I love a dirty hack as much as the next guy.

So here's the latest....

Here's the debug output.

Message

* Form passed first SPAM check OK
* Form passed the submissions limit (if enabled) OK
* Form passed the Image verification (if enabled) OK
* Form passed the server side validation (if enabled) OK
* Form passed the plugins step (if enabled) OK
* Emails data loaded OK
* Form passed all before email code evaluation OK
* An email has been SENT successfully from [stuff removed]
* Debug End

_POST: Array ( [eventid] => [userid] => [username] => [email] => [Event_Name] => [Location] => [Opening_Date] => [Closing_Date] => [Performers] => [Doors_Open] => [Show_Time] => [Closing_Time] => [Ticket_Price] => [web_site] => [Additional_Information] => [sf_message] => [9bed68fd1e6ba963e675a1d5cd55f26e] => 1 )



The empty email message follows this.

Now. In the script that goes BEFORE the email, if I go exit(print_r($_POST)) with debug ON I get:

The above post array followed by my populated post array.

If I go exit('') with debug ON I get the above post array ONLY.

I think that this means that the email is getting sent before my script runs.

No really, I'm not nuts!
nml375 09 Jul, 2009
The Serverside validation code is among the very first thing that gets executed, as it's intended use is to allow you to prevent further (any) processing if the submitted data does not meet some criteria. As such, this has to be evaluated long before any email is sent.

I find it odd that the fields are added to the $_POST array, but not it's values...
Think you could add some print_r($send_values) to your after submit code?

Also, did you create your own email template and check the "Form Field names" and "Form Field types"?

/Fredrik
nfg 09 Jul, 2009
Hi Fredrik,

The whole purpose of this is that the user input can be nicely cleaned in specific ways and tested for HTML output before posting. In addition a real copy of the exact HTML being posted gets sent to the moderator before the post can be approved. The email template would not be a real copy. I'm using that same routine to generate this HTML as I am to lay out the post as it is displayed to the public. Everybody sees an exact copy of the post, the way it will be laid out, even if I update the routine. The email templates if CF can't do that, so I made my own.

I've checked and rechecked my field names and types.

I've remade the entire form in the most default way.

I do not know what I am missing.

Here's the output you requested:

Array
(
    [eventid] => QTEyNDcxNjAxNDIw
    [userid] => 0
    [username] => 
    [email] => 
    [Event_Name] => A really small event
    [Location] => A big sort of place
    [Opening_Date] => Date formatted incorrectly. Click edit to change.
    [Closing_Date] => Date formatted incorrectly. Click edit to change.
    [Performers] => 12 acts from Thailand
    [Doors_Open] => 6:00
    [Show_Time] => 8:00 AM
    [Closing_Time] => 4 AM
    [Ticket_Price] => $15.00 at the door $12 online
    [web_site] => http://www.zuill.com
    [Additional_Information] => event descriptionevent descriptionevent descriptionevent descriptionevent descriptionevent descriptionevent descriptionevent descriptionevent descriptionevent descriptionevent descriptionevent descriptionevent descriptionevent descriptionevent descriptionevent descriptionevent descriptionevent description
    [sf_message] => <link href="[stuff removed]/templates/berd0002/css/template.css" rel="stylesheet" type="text/css"/><div class ="berdcal"><div class="berdcal_head"><span class="berdcal_date"> <span class="blabel">to</span> </div><div class="berdcal_title">A really small event</div><div class="berdcal_perf"><div class="blabel">Location:</div> A big sort of place</div><div class="berdcal_perf"><div class="blabel">Performing:</div> 12 acts</div><div class="berdcal_doors"><div class="blabel">Doors Open: </div> 6:00</div><div class="berdcal_time"><div class="blabel">Showtime:</div> 8:00 AM to 4 AM</div><div class="berdcal_price"><div class="blabel">Tickets:</div> $15.00 at the door $12 online</div><div class="berdcal_web"><div class="blabel">Web Site:</div> <a href="http://www.zuill.com" target="_blank">http://www.zuill.com</a></div><div class="berdcalcopy">event descriptionevent descriptionevent descriptionevent descriptionevent descriptionevent descriptionevent descriptionevent descriptionevent descriptionevent descriptionevent descriptionevent descriptionevent descriptionevent descriptionevent descriptionevent descriptionevent descriptionevent description</div></div>

    [9bed68fd1e6ba963e675a1d5cd55f26e] => 1
)
1
nml375 09 Jul, 2009
Been reading through the source of CFv3.0 over and over.. and frankly, the only thing I can think of, is that either the $send_values session data does not survive into Form2, or the email template lacks field holders:
Posted code follows:
{sf_message}


Do you think you could post a backup of each form?

/Fredrik
nfg 09 Jul, 2009

Been reading through the source of CFv3.0 over and over.. and frankly, the only thing I can think of, is that either the $send_values session data does not survive into Form2, or the email template lacks field holders:

Posted code follows:
{sf_message}


Do you think you could post a backup of each form?

/Fredrik



Wow Fredrik,

It's very kind of you to put so much effort into my miserable problem.

There is no question of the form not carrying over, nor of the fields not being available. Again I have checked and rechecked these things. The form preview could never work if the values from form 1 did not make it to form 2. In addition, the re-population of form 1 wouldn't work either. Also the data is written to the DB correctly suggesting that everything is coming through the process fine. Everything works swimmingly right up to the moment that the email gets sent.

My only solution at this point would seem to be to turn off the editor in the email template and place my PHP code there. Very rude way to do it.
nfg 10 Jul, 2009
I think I've got this licked.

Aside from the fact that I'm hacking chronocontact.php can anyone think of a reason why I should not do this.

What is happening is that in chronocontact.php a block with the comment "Associate field values with names and implode arrays" (line 735???) runs before the block with the comment "Run the On-submit 'pre e-mail' code if there is any" (about 30 lines down). It runs on the post array as it is taken from the form - ie: blank.

Somewhat below this the variable holding the post array gets reloaded, this time with the modified post array.
So now CF has two copies of the data. One is empty and the other is populated by me. The second goes to the DB the first goes to the email, and that's why my email is always empty.

If I move the block "Associate field values with names and implode arrays" to a point just below the block "Run the On-submit 'pre e-mail' code if there is any" then I get all of my values included in the email. Code follows:
<span class="syntaxdefault"></span><span class="syntaxcomment">// NFG : the block of code I moved is just above here<br /></span><span class="syntaxdefault">        </span><span class="syntaxcomment">/**<br />         * Loop the Emails<br />         */<br /></span><span class="syntaxdefault">        $database </span><span class="syntaxkeyword">=&</span><span class="syntaxdefault"> JFactory</span><span class="syntaxkeyword">::</span><span class="syntaxdefault">getDBO</span><span class="syntaxkeyword">();<br /></span><span class="syntaxdefault">        $query </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> </span><span class="syntaxstring">"SELECT * FROM #__chrono_contact_emails WHERE formid = '"</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">$rows</span><span class="syntaxkeyword">[</span><span class="syntaxdefault">0</span><span class="syntaxkeyword">]-></span><span class="syntaxdefault">id</span><span class="syntaxkeyword">.</span><span class="syntaxstring">"'"</span><span class="syntaxkeyword">;<br /></span><span class="syntaxdefault">        $database</span><span class="syntaxkeyword">-></span><span class="syntaxdefault">setQuery</span><span class="syntaxkeyword">(</span><span class="syntaxdefault"> $query </span><span class="syntaxkeyword">);<br /></span><span class="syntaxdefault">        $emails </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> $database</span><span class="syntaxkeyword">-></span><span class="syntaxdefault">loadObjectList</span><span class="syntaxkeyword">();<br /></span><span class="syntaxdefault">        $emailscounter </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> 0</span><span class="syntaxkeyword">;</span><span class="syntaxdefault"> <br />       <br /><br />        if </span><span class="syntaxkeyword">(</span><span class="syntaxdefault"> $debug </span><span class="syntaxkeyword">)</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">{<br /></span><span class="syntaxdefault">            $mainframe</span><span class="syntaxkeyword">-></span><span class="syntaxdefault">enqueueMessage</span><span class="syntaxkeyword">(</span><span class="syntaxstring">'Emails data loaded OK'</span><span class="syntaxkeyword">);<br /></span><span class="syntaxdefault">        </span><span class="syntaxkeyword">}<br /></span><span class="syntaxdefault">        </span><span class="syntaxcomment">/**<br />         * Run the On-submit 'pre e-mail' code if there is any<br />         */<br /></span><span class="syntaxdefault">        if </span><span class="syntaxkeyword">(</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">!empty(</span><span class="syntaxdefault">$rows</span><span class="syntaxkeyword">[</span><span class="syntaxdefault">0</span><span class="syntaxkeyword">]-></span><span class="syntaxdefault">onsubmitcodeb4</span><span class="syntaxkeyword">)</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">)</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">{<br /></span><span class="syntaxdefault">            eval</span><span class="syntaxkeyword">(</span><span class="syntaxdefault"> </span><span class="syntaxstring">"?>"</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">$rows</span><span class="syntaxkeyword">[</span><span class="syntaxdefault">0</span><span class="syntaxkeyword">]-></span><span class="syntaxdefault">onsubmitcodeb4 </span><span class="syntaxkeyword">);<br /></span><span class="syntaxdefault">        </span><span class="syntaxkeyword">}<br /></span><span class="syntaxdefault">        if</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">$paramsvalues</span><span class="syntaxkeyword">-></span><span class="syntaxdefault">savedataorder </span><span class="syntaxkeyword">==</span><span class="syntaxdefault"> </span><span class="syntaxstring">'before_email'</span><span class="syntaxkeyword">){<br /></span><span class="syntaxdefault">            if </span><span class="syntaxkeyword">(</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">!empty(</span><span class="syntaxdefault">$rows</span><span class="syntaxkeyword">[</span><span class="syntaxdefault">0</span><span class="syntaxkeyword">]-></span><span class="syntaxdefault">autogenerated</span><span class="syntaxkeyword">)</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">)</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">{<br /></span><span class="syntaxdefault">                eval</span><span class="syntaxkeyword">(</span><span class="syntaxdefault"> </span><span class="syntaxstring">"?>"</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">$rows</span><span class="syntaxkeyword">[</span><span class="syntaxdefault">0</span><span class="syntaxkeyword">]-></span><span class="syntaxdefault">autogenerated </span><span class="syntaxkeyword">);<br /></span><span class="syntaxdefault">            </span><span class="syntaxkeyword">}<br /></span><span class="syntaxdefault">        </span><span class="syntaxkeyword">}<br /><br /></span><span class="syntaxdefault">        if </span><span class="syntaxkeyword">(</span><span class="syntaxdefault"> $debug </span><span class="syntaxkeyword">)</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">{<br /></span><span class="syntaxdefault">            $mainframe</span><span class="syntaxkeyword">-></span><span class="syntaxdefault">enqueueMessage</span><span class="syntaxkeyword">(</span><span class="syntaxstring">'Form passed all before email code evaluation OK'</span><span class="syntaxkeyword">);<br /></span><span class="syntaxdefault">        </span><span class="syntaxkeyword">}<br /><br /></span><span class="syntaxdefault">        $posted </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> JRequest</span><span class="syntaxkeyword">::</span><span class="syntaxdefault">get</span><span class="syntaxkeyword">(</span><span class="syntaxdefault"> </span><span class="syntaxstring">'post'</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> JREQUEST_ALLOWRAW </span><span class="syntaxkeyword">);<br /></span><span class="syntaxcomment">// NFG : Note this JRequest here. This picks up the newly populated array<br />// NFG : This is where I moved the code block to<br /></span><span class="syntaxdefault">        </span><span class="syntaxcomment">/*<br />         * Associate field values with names and implode arrays<br />         */<br /></span><span class="syntaxdefault">        $fields </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> array</span><span class="syntaxkeyword">();<br /></span><span class="syntaxdefault">        $names </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> explode</span><span class="syntaxkeyword">(</span><span class="syntaxstring">","</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> $rows</span><span class="syntaxkeyword">[</span><span class="syntaxdefault">0</span><span class="syntaxkeyword">]-></span><span class="syntaxdefault">fieldsnames</span><span class="syntaxkeyword">);<br /></span><span class="syntaxdefault">        foreach </span><span class="syntaxkeyword">(</span><span class="syntaxdefault"> $names as $name </span><span class="syntaxkeyword">)</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">{<br /></span><span class="syntaxdefault">            if</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">$paramsvalues</span><span class="syntaxkeyword">-></span><span class="syntaxdefault">handlepostedarrays </span><span class="syntaxkeyword">==</span><span class="syntaxdefault"> </span><span class="syntaxstring">'Yes'</span><span class="syntaxkeyword">){<br /></span><span class="syntaxdefault">                if </span><span class="syntaxkeyword">(</span><span class="syntaxdefault"> is_array</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">$posted</span><span class="syntaxkeyword">[</span><span class="syntaxdefault">$name</span><span class="syntaxkeyword">]))</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">{<br /></span><span class="syntaxdefault">                    $fields</span><span class="syntaxkeyword">[</span><span class="syntaxdefault">$name</span><span class="syntaxkeyword">]</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> implode</span><span class="syntaxkeyword">(</span><span class="syntaxstring">", "</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> $posted</span><span class="syntaxkeyword">[</span><span class="syntaxdefault">$name</span><span class="syntaxkeyword">]);<br /></span><span class="syntaxdefault">                </span><span class="syntaxkeyword">}</span><span class="syntaxdefault"> else </span><span class="syntaxkeyword">{<br /></span><span class="syntaxdefault">                    $fields</span><span class="syntaxkeyword">[</span><span class="syntaxdefault">$name</span><span class="syntaxkeyword">]</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> $posted</span><span class="syntaxkeyword">[</span><span class="syntaxdefault">$name</span><span class="syntaxkeyword">];<br /></span><span class="syntaxdefault">                </span><span class="syntaxkeyword">}<br /></span><span class="syntaxdefault">            </span><span class="syntaxkeyword">}else{<br /></span><span class="syntaxdefault">                $fields</span><span class="syntaxkeyword">[</span><span class="syntaxdefault">$name</span><span class="syntaxkeyword">]</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> $posted</span><span class="syntaxkeyword">[</span><span class="syntaxdefault">$name</span><span class="syntaxkeyword">];<br /></span><span class="syntaxdefault">            </span><span class="syntaxkeyword">}<br /></span><span class="syntaxdefault">        </span><span class="syntaxkeyword">}<br /></span><span class="syntaxdefault">        foreach</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">$emails as $email</span><span class="syntaxkeyword">){<br /></span><span class="syntaxdefault">            $registry_email </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> new JRegistry</span><span class="syntaxkeyword">();<br /></span><span class="syntaxdefault">            $registry_email</span><span class="syntaxkeyword">-></span><span class="syntaxdefault">loadINI</span><span class="syntaxkeyword">(</span><span class="syntaxdefault"> $email</span><span class="syntaxkeyword">-></span><span class="syntaxdefault">params </span><span class="syntaxkeyword">);<br /></span><span class="syntaxdefault">            $email_params </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> $registry_email</span><span class="syntaxkeyword">-></span><span class="syntaxdefault">toObject</span><span class="syntaxkeyword">(</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">);<br /></span><span class="syntaxdefault">            if </span><span class="syntaxkeyword">(</span><span class="syntaxdefault"> $email</span><span class="syntaxkeyword">-></span><span class="syntaxdefault">enabled </span><span class="syntaxkeyword">==</span><span class="syntaxdefault"> </span><span class="syntaxstring">"1"</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">)</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">{<br /></span><span class="syntaxdefault">                </span><span class="syntaxcomment">//if ( $debug ) { echo "Use template<br />"; }<br /></span><span class="syntaxdefault">                $email_body </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> $email</span><span class="syntaxkeyword">-></span><span class="syntaxdefault">template</span><span class="syntaxkeyword">;<br /></span><span class="syntaxdefault">                ob_start</span><span class="syntaxkeyword">();<br /></span><span class="syntaxdefault">                eval</span><span class="syntaxkeyword">(</span><span class="syntaxdefault"> </span><span class="syntaxstring">"?>"</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">$email_body </span><span class="syntaxkeyword">);<br /></span><span class="syntaxdefault">                $email_body </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> ob_get_clean</span><span class="syntaxkeyword">();<br /></span><span class="syntaxdefault">                </span><span class="syntaxcomment">//ob_end_clean();<br />// NFG : Becuase the code block was moved the $fields array now has useful data that includes changes to the <br />//       post array made in the "before email" block.<br /></span><span class="syntaxdefault">                </span><span class="syntaxcomment">//build emial template from defined fields and posted fields<br /></span><span class="syntaxdefault">                foreach </span><span class="syntaxkeyword">(</span><span class="syntaxdefault"> $fields as $name </span><span class="syntaxkeyword">=></span><span class="syntaxdefault"> $post</span><span class="syntaxkeyword">)</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">{<br /></span><span class="syntaxdefault">                    $email_body </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> str_replace</span><span class="syntaxkeyword">(</span><span class="syntaxstring">"{"</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">$name</span><span class="syntaxkeyword">.</span><span class="syntaxstring">"}"</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> $post</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> $email_body</span><span class="syntaxkeyword">);<br /></span><span class="syntaxdefault">                </span><span class="syntaxkeyword">}<br /></span><span class="syntaxdefault">                foreach </span><span class="syntaxkeyword">(</span><span class="syntaxdefault"> $posted as $name </span><span class="syntaxkeyword">=></span><span class="syntaxdefault"> $post</span><span class="syntaxkeyword">)</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">{<br /></span><span class="syntaxdefault">                    if</span><span class="syntaxkeyword">(!</span><span class="syntaxdefault">is_array</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">$post</span><span class="syntaxkeyword">))<br /></span><span class="syntaxdefault">                    </span><span class="syntaxkeyword">{</span><span class="syntaxdefault">$email_body </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> str_replace</span><span class="syntaxkeyword">(</span><span class="syntaxstring">"{"</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">$name</span><span class="syntaxkeyword">.</span><span class="syntaxstring">"}"</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> $post</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> $email_body</span><span class="syntaxkeyword">);}<br /></span><span class="syntaxdefault">                    else<br />                    </span><span class="syntaxkeyword">{</span><span class="syntaxdefault">$email_body </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> str_replace</span><span class="syntaxkeyword">(</span><span class="syntaxstring">"{"</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">$name</span><span class="syntaxkeyword">.</span><span class="syntaxstring">"}"</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> implode</span><span class="syntaxkeyword">(</span><span class="syntaxstring">", "</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> $post</span><span class="syntaxkeyword">),</span><span class="syntaxdefault"> $email_body</span><span class="syntaxkeyword">);}<br /></span><span class="syntaxdefault">                </span><span class="syntaxkeyword">}</span><span class="syntaxdefault"> </span>
nml375 10 Jul, 2009
Hi nfg,
I'll leave the final word regarding hacking to Max, although I think as long as you don't touch the backlink in the non-registered version you'll be fine.

Moving that block should do the trick indeed, however, I am confused that moving the "restore-code" into the Serverside Validation (and enabling this) box did not work. This part is executed long before the above mentioned block of code.

/Fredrik
nfg 10 Jul, 2009
Sorry Fredrik,

I obviously was not paying full attention.

I am confused that moving the "restore-code" into the Serverside Validation (and enabling this) box did not work. This part is executed long before the above mentioned block of code.

/Fredrik



It did not dawn on me until now what you meant by this. I've done all this and could have listened to you and saved a whole lot of time. Thanks for pointing this out, and if it appears that I am a dolt I don't really feel that bad about it. At least the thing will work a little better for it, and now I know WHY it was happening. That was becoming obsessively important to me.

You are exactly right. I will review my script and see if the relevant bit can't be transferred, then I can leave the component well enough alone. I much prefer it that way.

That said, I'm still curious if moving this code is not helpful. Is there a situation where we want two potentially different copies of the post data?
nml375 11 Jul, 2009
No worries.
Just make sure you don't echo/print/output anything in the serverside validation code, or you'll notice things breaking apart (if you decide to use it).

The use of the $fields array I believe is used to only retrieve the field'n'values listed in the "Fields names list", rather than the whole list of posted fields.

I do notice an odd behaviour later during the field substitution...
First the $fields array is iterated and replaced in the template (in your case removing all the field holders).
Next, the $posted array (holding a more recent copy of the posted fields - affected by JRequest::setVar()) is iterated as well, although all valid field holders have already been removed in the earlier step.
I'm not sure if this is a bug or undocumented behaviour, but it actually renders the "Fields names list" pretty much useless (except for the DB Connection setup)?

/Fredrik
nfg 11 Jul, 2009

I do notice an odd behaviour later during the field substitution...
First the $fields array is iterated and replaced in the template (in your case removing all the field holders).
Next, the $posted array (holding a more recent copy of the posted fields - affected by JRequest::setVar()) is iterated as well, although all valid field holders have already been removed in the earlier step.
I'm not sure if this is a bug or undocumented behaviour, but it actually renders the "Fields names list" pretty much useless (except for the DB Connection setup)?



That's precisely the point of my last, and the object of my curiosity.
This topic is locked and no more replies can be posted.