I have been unable to get a simple form to submit via Ajax.  Can
anyone help?  I am presented with this error:

Fatal error: Call to undefined method
RequestHandlerComponent::setAjax() in /home/ssdcmgr/public_html/alpha/
app/controllers/mailing_list_controller.php on line 11


Here is my view:

<h1><?php __('subscribe') ?></h1>

<div id="subscribe">
        <?= $form->create('MailingList', array('url' => '/mailing_list')) ?>
        <?//= $ajax->form('MailingList', array('url' => '/mailing_list')) ?>
        <?//= $ajax->form(array('action' => '/mailing_list'), 'post',
array('update' => 'subscribe')) ?>

        <?= $form->input('email', array('maxlength' => 30)) ?>
        <?= $form->radio('subscribe', array('subscribe' => __('subscribe',
true), 'unsubscribe' => __('unsubscribe', true))) ?>

        <?= $form->end(__('submit', true)) ?>
        <?//= $ajax->submit() ?>
</div>


Here is my controller:

class MailingListController extends AppController {
        var $name = 'MailingList';
        var $uses = array('MailingList');
        var $components = array('Email', 'RequestHandler');
        var $helpers = array('Ajax');

        function index() {
                //$this->layout = 'ajax';
                $this->RequestHandler->setAjax($this);

                if (isset($this->data)) {
                        if ($this->MailingList->create($this->data) && 
$this->MailingList-
>validates()) {

                                if ($this->data['MailingList']['subscribe'] == 
'subscribe') {
                                        $subject = 'subscribe';
                                } else {
                                        $subject = 'unsubscribe';
                                }

                                $this->Email->sendAs = 'both'; // html, text, 
both

                                $this->Email->to = '[EMAIL PROTECTED]';
                                $this->Email->from = 
$this->data['MailingList']['email'];
                                $this->Email->subject = $subject;

                                if ($this->Email->send()) {
                                        if ($subject == 'subscribe') {
                                                
$this->Session->setFlash(__('subscribeSent', true));
                                        } else {
                                                
$this->Session->setFlash(__('unsubscribeSent', true));
                                        }
                                }
                        }
                } else {
                        // set default radio button
                        $this->data['MailingList']['subscribe'] = 'subscribe';
                }

        }
}

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to