email on form submission not working for me

Status
Not open for further replies.

jbadiag

Member
I'm trying to send an email if the value of a field it's = 1, depending on a Yes/no field
I have this text in the php conditional
PHP:
$aprovat = $formModel->formData["vacancesap___aprovacio[]"];
if ($aprovat == 0){
return false;
}

But always send the email. What I'm doing wrong?
Thanks
 
Try
Code:
$aprovat = $formModel->formData["vacancesap___aprovacio_raw"];
if ((int)$aprovat == 0){
return false;
}
 
It may or may not still be an array at that point, if it's a join. So I usually do this, just in case ...

Code:
$aprovat = $formModel->formData["vacancesap___aprovacio_raw"];
$aprovat = is_array($aprovat) ? $aprovat[0] : $aprovat;
return (int)$aprovat !== 0;

-- hugh
 
It may or may not still be an array at that point, if it's a join. So I usually do this, just in case ...

Code:
$aprovat = $formModel->formData["vacancesap___aprovacio_raw"];
$aprovat = is_array($aprovat) ? $aprovat[0] : $aprovat;
return (int)$aprovat !== 0;

-- hugh
Hi,
none of the two formulas works. Does not send the mail with this code.
I don't know what to do, i'm lost...
That's what I have... attach image
Thanks
 

Attachments

  • Captura.JPG
    Captura.JPG
    57.4 KB · Views: 151
Better use
$formModel->getElementData('vacancesap___aprovacio',true);
http://fabrikar.com/forums/index.php?wiki/php-form-plugin/#accessing-form-data

(in the email form plugin $formModel->formData needs the short element name $formModel->formData["aprovacio_raw"];)

For debugging you can do
Code:
$aprovat = $formModel->getElementData('vacancesap___aprovacio',true);
var_dump($aprovat);exit;
$aprovat = is_array($aprovat) ? $aprovat[0] : $aprovat;
return (int)$aprovat !== 0;
 
Better use
$formModel->getElementData('vacancesap___aprovacio',true);
http://fabrikar.com/forums/index.php?wiki/php-form-plugin/#accessing-form-data

(in the email form plugin $formModel->formData needs the short element name $formModel->formData["aprovacio_raw"];)

For debugging you can do
Code:
$aprovat = $formModel->getElementData('vacancesap___aprovacio',true);
var_dump($aprovat);exit;
$aprovat = is_array($aprovat) ? $aprovat[0] : $aprovat;
return (int)$aprovat !== 0;

Finally works! That was the solution.

Code:
$aprovat = $formModel->getElementData('vacancesap___aprovacio',true);
$aprovat = is_array($aprovat) ? $aprovat[0] : $aprovat;
return (int)$aprovat !== 0;
[/QUOTE]

Thank you very much!!!
 
I'm getting dumber. I didn't notice that was accessing the array directly. Yup, that's why I wrote the getElementData() method, to hide the long vs short element name issue. Should always be used in any kind of form submission context rather than directly accessing the formData array.



Sent from my HTC One using Tapatalk
 
Status
Not open for further replies.
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top