<?xml version="1.0" encoding="utf-8"?>
		<feed xmlns="http://www.w3.org/2005/Atom">
			<title type="text">Akelos PHP Framework Forum - [solved] How to get a Form&amp;#039;s Inputfield values for AkActionMailer?</title>
			<updated>2010-09-06T09:32:35+02:00</updated>
			<id>http://forum.akelos.org/</id>
			<link rel="alternate" type="text/html" hreflang="en"
				href="http://forum.akelos.org/discussion/?DiscussionID=843&amp;page=1"/>
			<link rel="self" type="application/atom+xml"
				href="http://forum.akelos.org/discussion/?DiscussionID=843&amp;Feed=ATOM&amp;page=1"/>
			<generator
				uri="http://getvanilla.com/"
				version="1.1.4">
				Lussumo Vanilla &amp; Feed Publisher
			</generator>
			<entry>
		<title>[solved] How to get a Form&#039;s Inputfield values for AkActionMailer?</title>
		<link rel="alternate" href="http://forum.akelos.org/discussion/843/?Focus=3319#Comment_3319" type="application/xhtml+xml" hreflang="en"/>
		<id>http://forum.akelos.org/discussion/843/?Focus=3319#Comment_3319</id>
		<published>2009-11-10T22:41:14+01:00</published>
		<updated>2009-11-11T22:20:39+01:00</updated>
		<author>
			<name>Oliver</name>
			<uri>http://forum.akelos.org/account/94/</uri>
		</author>
		<summary type="text" xml:lang="en">
			Hi everybody,

I am stuck with the AkActionMailer. I somehow miss something between gather the Form's inputfield-values and use them to send e-mails. I followed the instructions in the ...
		</summary>
		<content type="html">
			<![CDATA[<p>Hi everybody,</p>

<p>I am stuck with the AkActionMailer. I somehow miss something between gather the Form's inputfield-values and use them to send e-mails. I followed the instructions in the <a href="http://www.akelos.org/wiki/sending-e-mail">/lib/AkActionMailer.php</a>. Here is what I did:</p>

<pre><code>./script/generate mailer Notifier contactNotification
</code></pre>

<p>Then I changed <strong>/models/notifier.php</strong> to the following:</p>

<pre><code>class Notifier extends AkActionMailer
{

  function contactNotification($params)
  {
    $this-&gt;set(array(
        'recipients'    =&gt; 'mymail@host.com',
        'from'          =&gt; $params['email'],
        'subject'       =&gt; $params['subject'],
        'contentType'   =&gt; 'text/html',
        'body'          =&gt; array(   'Sender'        =&gt; $params['email'],
                            'Subject'       =&gt; $params['subject'],
                            'Message'       =&gt; $params['message']),
        'headers'       =&gt; array(   'MIME-Version'  =&gt; '1.0',
                            'Reply-To'      =&gt; $params['email'],
                            'X-Mailer'      =&gt; 'PHP/'.phpversion())
    ));
  }   
}
</code></pre>

<p>The <strong>/views/notifier/contactNotification.tpl</strong> look like this (but here I want to have all fields from the form available...):</p>

<pre><code>&lt;html&gt;
  &lt;body&gt;
    &lt;h1&gt;{$Subject} by {$Sender}&lt;/h1&gt;
    {$Message}
  &lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p>In my <strong>Application Controller</strong> I have:</p>

<pre><code>function submit()
{
    if (!empty($this-&gt;params['contact']['email']))
    {
        if (empty($this-&gt;params['contact']['message']))
        {
            $this-&gt;flash['error'] = $this-&gt;t('&lt;b&gt;No Message&lt;/b&gt; This is a required field.');

        } else {
            Ak::import_mailer('notifier');
    $Notifier = new Notifier();
    if ($Notifier-&gt;deliver('contactNotification', $this-&gt;params['contact']))
            {
                $this-&gt;flash['tip'] = $this-&gt;t('&lt;b&gt;Thank You!&lt;/b&gt; We received your message.');

            } else {

                $this-&gt;flash['error'] = $this-&gt;t('&lt;b&gt;An Error occured&lt;/b&gt; Please try again.');
            }
        }

    } else {

        $this-&gt;flash['error'] = $this-&gt;t('&lt;b&gt;No E-Mail&lt;/b&gt; We need this to contact you.');
    }

    $this-&gt;redirectTo('index');
}
</code></pre>

<p>And the <strong>HTML Form in the template</strong> looks like this:</p>

<pre><code>&lt;?php $contact_form = $form_helper-&gt;form_for('contact', $Contact, array('url' =&gt; array('action' =&gt; 'submit'))); ?&gt;
  &lt;b&gt;_{Name}&lt;/b&gt;        &lt;?= $contact_form-&gt;text_field('name'); ?&gt;&lt;br /&gt;
  &lt;b&gt;_{eMail}&lt;/b&gt;       &lt;?= $contact_form-&gt;text_field('email'); ?&gt;&lt;br /&gt;
  &lt;b&gt;_{Subject}&lt;/b&gt;     &lt;?= $form_options_helper-&gt;select('contact', 'subject', array('Contact me', 'Question', 'Information', 'General/Other')) ?&gt;&lt;br /&gt;
  &lt;b&gt;_{Message}&lt;/b&gt;     &lt;?= $contact_form-&gt;text_area('message') ?&gt;&lt;br /&gt;
  &lt;input type="submit" value="_{Send}" /&gt;
&lt;?= $contact_form-&gt;end_form_tag(); ?&gt;
</code></pre>

<p><strong>When I send the form (with valid data), I get the message</strong>: "Fatal error: Class 'Notifier' not found in /myproject/app/controllers/myproject_controller.php"</p>

<p>I think I have also some basic misunderstanding in handling this. How can I access the mailer model? Forbear with me, as I am just very new to Akelos.</p>

<p>Anyway, appreciate all your help,<br />
Oliver</p>
]]>
		</content>
	</entry>
	<entry>
		<title>[solved] How to get a Form&#039;s Inputfield values for AkActionMailer?</title>
		<link rel="alternate" href="http://forum.akelos.org/discussion/843/?Focus=3320#Comment_3320" type="application/xhtml+xml" hreflang="en"/>
		<id>http://forum.akelos.org/discussion/843/?Focus=3320#Comment_3320</id>
		<published>2009-11-10T23:10:40+01:00</published>
		<updated>2010-09-06T09:32:35+02:00</updated>
		<author>
			<name>Oliver</name>
			<uri>http://forum.akelos.org/account/94/</uri>
		</author>
		<summary type="text" xml:lang="en">
			Well, I guess you can forget it - looks like I was able to solve it thank to (this Discussion)[http://forum.akelos.org/discussion/527/] :)

I edited my initial post so it shows now the working ...
		</summary>
		<content type="html">
			<![CDATA[<p>Well, I guess you can forget it - looks like I was able to solve it thank to (this Discussion)[http://forum.akelos.org/discussion/527/] :)</p>

<p>I edited my initial post so it shows now the working code...</p>

<p>However, I'd appreciate any comments on the code above if there are thing I could to "better".</p>
]]>
		</content>
	</entry>
	
		</feed>