Welcome Guest, Not a member yet? Register   Sign In
Pass variable to view for HTML email
#1

(This post was last modified: 04-05-2023, 10:05 AM by eleumas.)

Hi, i have this code in my controller:
PHP Code:
$formData = \Config\Services::request()->getPost();
            
$this
->email->setTo('[email protected]');
$this->email->setFrom($formData['email'], $formData['name'] . ' ' $formData['surname']);
$myView view('mail');
$this->email->setMessage($myView); 

The code in my view 'mail':
Code:
<!DOCTYPE html>
<html>
<head>
    <title>My mail view</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
    <table>
        <tbody>
            <tr>
                <td class="label">Nome Azienda:</td>
            </tr>
            <tr>
                <td><?php echo $formData['nome_azienda'];?></td>
            </tr>

            <tr>
                <td class="label">Nome:</td>
            </tr>
            <tr>
                <td><?php echo $formData['name'];?></td>
            </tr>   
      </tbody>
    </table>
</body>
</html>

I have this error: undefined variable $formData
How can is solve this issue and pass the variable to my view 'mail'?
Thanks for help me.

SOLVED.

I put 
Code:
$formData = \Config\Services::request()->getPost(); 
in my view.
Reply
#2

(This post was last modified: 04-05-2023, 10:15 AM by JustJohnQ.)

$myView view('mail', $formdata);
??
Reply




Theme © iAndrew 2016 - Forum software by © MyBB