Here is how I use it.

<h3>Quick Add (Task)</h3>
<?php echo $form->create('Task',array('onSubmit'=>'return false'));?>

<?php
    echo  $form->input('Task/name');
    echo $form->hidden('Task/project_id',array('value'=>
$project['Project']['id']));
    echo $ajax->submit('Quick Add', array('url'=>'/tasks/quickadd/' .
$project['Project']['id'], 'update'=>'open_tasks'));
?>
</form>

And then in my tasks_controller, here is my quickadd action.

        function quickadd($project_id) {
                // adds new task to database
                if (!empty($this->params['data'])) {
            $this->data['Task']['creator_id'] = $this->Session-
>read('User.id');
            $this->data['Task']['completed'] = '0';
                        $this->Task->create();
                        if ($this->Task->save($this->params['data'])) {
                $this->set('project_id', $project_id);
                        $this->set('opentasks', $this-
>paginate(null,array('Task.project_id'=>
$project_id,'Task.completed'=>'!=1')));
                                $this->render('opentasks', 'ajax');
                        }
                }
        }

I am not doing all the error checking I need to yet, but it is
functional and works nicely!!


On May 18, 4:06 am, "[EMAIL PROTECTED]"
<[EMAIL PROTECTED]> wrote:
> I've forgetten to say that the div "viewadmin" in another view (the
> index.html) where initially I've loaded modify.html and then I would
> load "controlName/actionName".
>
> On 18 Mag, 10:48, "[EMAIL PROTECTED]"
>
> <[EMAIL PROTECTED]> wrote:
> > I'm new in CakePHP
> > I have a question.
> > Can anyone make me an example of use of $ajax->submit?
>
> > My code is:
>
> > <!-- modify.thtml -->
> > <form>
> > <p>
> >         Input:<?php echo $html->input('input/input',
>
> > array('size'=> '60','value'=>0))?>
> > </p>
>
> >  <?php
> >         $options=array( 'update'        => 'viewadmin',
> >                         'url'           => '/controlName/
> > actionName'  );
> >         echo $ajax->submit('Save', $options);
> >    ?>
> > </p>
> > </form>
> > </div>
> > <div id=viewadmin></div>
>
> > When I click on "Save" I don't get anything in the div "viewadmin".
> > Why?
>
> > Many Thanks


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
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