I am having a problem with my AJAX form submit and can't quite see a
solution in the groups. I also couldn't find any recent (~2008)
tutorials on getting AJAX to work in CakePHP. I have seen some people
who have just gone on to use JQuery, but I'd rather not.

My problem is that the form data never makes it to the controller
($this->data, $this->params['data'] and $this->params['form'] are
empty.

I have enabled the JS and AJAX helpers as well as the RequestHandler
component. I added <?php
echo $javascript->link('prototype');
echo $javascript->link('scriptaculous.js?load=effects')
?> in the head of the default.ctp.

The div I am updating displays the echos and debugs in my controller,
so I know the action is triggering. Below is my view. It basically
allows the assignment of a one to many relationship (Project has many
Stuff, Stuff has one Project). Any ideas what I could be missing or
have some clues as how I can trace the issue?

-------------------
        <div id="west">



    <fieldset>
    <legend>Projects</legend>
        <table id="worksheet">
                <?php echo $this->renderElement('active_filters');?>
        <?php
            $form_params = array('update' => 'status',
'model'=>'Project', 'url' => array('controller' => 'projects',
'action' => 'assign'));
                        echo $ajax->form('assign','post', $form_params);
                ?>

        <?php
                $options  = array('legend'=>'','div'=>true,'separator'=>'<br /
>','value'=>'');
                echo $form->radio('Project.id', $projects, $options);
         ?>
                </fieldset>
    </table>
        </div>

    <div id="east">
    <table id="worksheet">
            <tr height="20">
            <td class="last">

                <?php
                        $options  = array('multiple'=>'checkbox');
                        echo $form->select('Stuff.id', $unassigned_stuff,
null, $options);
                ?>
            </td>
            </tr>
        </table>
        </div>

-------------

Here is the dump of the $this->params array:
Array
(
    [pass] => Array
        (
        )

    [named] => Array
        (
        )

    [controller] => projects
    [action] => assign
    [plugin] =>
    [url] => Array
        (
            [ext] => html
            [url] => projects/assign
        )

    [form] => Array
        (
        )

    [isAjax] => 1
)

----------
Here's the form created by the helper:

        <form id="form1937661850" onsubmit="event.returnValue = false;
return false;" method="post" action="/app_name/projects/
assign"><fieldset style="display:none;"><input type="hidden"
name="_method" value="POST" /></fieldset><script type="text/
javascript">
//<![CDATA[
Event.observe('form1937661850', 'submit', function(event) { new
Ajax.Updater('status','/app_name/projects/assign', {asynchronous:true,
evalScripts:true, parameters:Form.serialize('form1937661850'),
requestHeaders:['X-Update', 'status']}) }, false);
//]]>
</script>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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