Error: Invalid argument supplied for foreach() Error type/ Nr.: Warning - 2 File: /home/roomd3/public_html/modx/assets/snippets/spform/spform.inc.php Line: 229 Line 229 source: foreach($options as $key => $description) {
This happened to me once and I can’t for the life of me remember why. Try turning on spfDebug and checking what ResponseURL is set to. If you’re previewing from the Manager, that could be causing the error. Try it from another browser as non-admin user.
I have an issue with spform, when a form submits the URL changes to spfresponse.?err=1 , resulting in a new page. spfresponse.htm?err=1 gives me the correct Thank You page. anywhere to look?
also for customizing the form fields, I can see in spform.inc.php the form but where do I change the email sent to include my add on fields?
This is where eForm is superior. SPForm is simpler, but not very flexible with respect to the form. With SPForm, you’d have to add your fields to the form in the code in SPForm.inc.php and then (in SPFormProc.inc.php) pull them from the $_POST data and append them to the $content variable (around line 515).
echo '<p><span class="spf_prompt">'.$spf_lang['marketing'].'</span><br />'; echo '<span class="spf_normal_input"><select name="marketing">'; echo '<option value="None">Please Select...</option>'; echo '<option value="Printed">Printed Advert</option>'; echo '<option value="Yell">Yell.com</option>'; echo '<option value="Search">Internet Search</option>'; echo '<option value="Word">Word of Mouth</option>'; echo '<option value="Other">Other</option>'; echo '</select>';
if(!empty($_POST['name'])) $content = $_POST['name'] .' '.$spf_lang['wrote']; $content .= preg_replace('/\r/', '', stripslashes($_POST['comments'])) . "\n" . "\n"; $content .= "Marketing response: " ; $content .= $_POST['marketing']; $addlHeaders = empty($_POST['email'])? "" : "From: " . $_POST['email'] . "\n" . "Reply-To: " . $_POST['email'] . "\n";
Deevee wrote: This is the text i want to send you
Marketing response:
http://www.twptown.org/spfresponse?OrigRef=http%3A%2F%2Fwww.twptown.org%2Fprivacy-policy&err=1
ResponseURL: http://www.twptown.org/spfresponse?OrigRef=http%3A%2F%2Fwww.twptown.org%2Fmission
It appears that you’ve uncovered a bug in SPForm that occurs when orig_referer is blank in the _POST.
$spfResponseArg = ""; if(!empty($_POST['orig_referer'])) { // if it's there, create arg for spfresponse to take user back $spfResponseArg .= "OrigRef=" . urlencode($_POST['orig_referer'].'"'); // needed for makeUrl } $responseURL = $modx->makeUrl($spfResponseID,'',$spfResponseArg,'full'); // $spfResponseID set in config file if(!empty($_POST['orig_referer'])) { $responseURL = substr_replace($responseURL, '', strlen($responseURL)-3); // strip trailing slash from original referrer string } if ($spfDebug) { echo "ResponseURL: ".$responseURL.'<br>'; } $modx->sendRedirect($responseURL,1);
// $spfResponseID set in config file $responseURL = $modx->makeUrl($spfResponseID, '', '', 'full'); // $spfResponseID set in config file $modx->sendRedirect($responseURL,1);