Please help my, I'm tearing my hair out here it's been literally HOURS trying to get this to work. I have another form on another site where it works perfectly.
I have a form where someone needs to upload 1 or 2 photos - not 0. I have two separate file upload fields, "certificatesRSA" and "certificatesWhiteCard".
I can perform a check to make sure at least one image has been attached:
It's messy but it's what I got working after a lot of troubleshooting.
NOW: since I'm using a TCPDF action, if the person only uploads one image then the other one needs to be replaced with a placeholder image so that TCPDF doesn't fail.
This same sort of thing works 100% on another site - I can get and set the value of the field in question using $_POST but I CANNOT FUC*&^ING GET IT TO WORK on this site! when I try to
PLEASE HELP ME I CAN'T GO TO SLEEP TIL I GET IT WORKING AND IT'S 11PM
Here's what works perfectly fine on the other site:
I have a form where someone needs to upload 1 or 2 photos - not 0. I have two separate file upload fields, "certificatesRSA" and "certificatesWhiteCard".
I can perform a check to make sure at least one image has been attached:
$hasNoRSA = empty($this->data("certificatesRSA", ""));
$hasNoWC = empty($this->data("certificatesWhiteCard", ""));
//Return true if both RSA and WC are empty
return ($hasNoRSA && $hasNoWC);
It's messy but it's what I got working after a lot of troubleshooting.
NOW: since I'm using a TCPDF action, if the person only uploads one image then the other one needs to be replaced with a placeholder image so that TCPDF doesn't fail.
if(empty ($this->data("certificatesRSA", "")))
$_POST["certificatesRSA"] = "noCertificate.png";
if (empty($this->data("certificatesWhiteCard", "")))
{
$_POST["certificatesWhiteCard"] = "noCertificate.png";
}
This same sort of thing works 100% on another site - I can get and set the value of the field in question using $_POST but I CANNOT FUC*&^ING GET IT TO WORK on this site! when I try to
echo $_POST[field name]
even the populated field I get NOTHING, even though the debug action shows there's something there.
PLEASE HELP ME I CAN'T GO TO SLEEP TIL I GET IT WORKING AND IT'S 11PM
Here's what works perfectly fine on the other site:
if(empty($_POST['photoIDAttachment']))
$_POST['photoIDAttachment'] = "noID.png";
DEBUG ACTION:
var_dump($_POST)
Array
(
................
[certificatesRSA] => pexels-photo.jpg
[certificatesWhiteCard] => pexels-photo.jpg
................
)
var_dump($_POST)
Array
(
................
[certificatesRSA] =>
[certificatesWhiteCard] =>
................
)
Hi healyhatman,
ChronoForms copies the contents of $_POST into $this->data when the form is submitted before any actions run so changing the $_POST values after that will not change the data that CF is using. If you use the equivalent $this->data entries it should be OK.
Bob
ChronoForms copies the contents of $_POST into $this->data when the form is submitted before any actions run so changing the $_POST values after that will not change the data that CF is using. If you use the equivalent $this->data entries it should be OK.
Bob
Hi,
The values can be set in the data array using:
Best regards,
Max
The values can be set in the data array using:
$this->data["key"] = "value"; //method #1
$this->data("key", "value", true); //method #2
Best regards,
Max
Thanks for that, I didn't see that anywhere in the guides.
This topic is locked and no more replies can be posted.