I created a plugin that handles all security issues with Cake / Ajax
requests.

 

Simply add a $this>_secureForm() which adds a _key and it adds a token to
the form and on request the _key matches the users _lock 

 

Controller will generate a new key  on every request.

 

All though it will not handle dynamic fields if added.  

But if you have a form with set fields it will grab the field names, hash
them and call it a lock and compare it to the key on every request......

 

 

 

Dave Maharaj

Freelance Designer | Developer
Description: header_logo
www.movepixels.com  |   <mailto:d...@movepixels.com> d...@movepixels.com  |
709.800.0852

 

From: cake-php@googlegroups.com [mailto:cake-php@googlegroups.com] On Behalf
Of euromark
Sent: Friday, August 16, 2013 5:10 PM
To: cake-php@googlegroups.com
Subject: Re: bootstrap twitter typeahead , dont work for me in cakephp

 

Never create a new response object

there is already one available in your controller

 

just use 

 

    $this->response->body($content);

 

as documented



Am Freitag, 16. August 2013 19:16:32 UTC+2 schrieb cesar calvo:

I use this in my AppController

public function jsonResponse($array) {
        return new CakeResponse(array('body' => json_encode($array)));
    }

Then on a controller call jsonResponse


Note: if you are usin Security component on beforeFilter:

if ($this->request->is('ajax')) $this->Security->unlockedActions =
array($this->request->action);

On Thursday, August 15, 2013 11:03:34 PM UTC-3, Renato Bigliazzi wrote:

Hi , I can not do the twitter bootstrap component typeahead work with cake.
i use https://github.com/rudylee/cbunny , but dont work form me.

 

 

In my view

 

JS

 

<script type="text/javascript">

 $(document).ready(function(){         

            $('#itemdesc').typeahead({

    source: function (query, process) {

      return $.ajax({

        url:'<?php echo
Router::url(array('controller'=>'Invoices','action'=>'localizaprodutos'));?>
',

        type: 'get',

        data: {q: query},

        dataType: 'json',

        success: function (json) {

          return process(json);

        }

      });

    }

  });

});

</script>

 

HTML

<input type="text" name="itemdesc[]"  class="input-large" id="itemdesc"
data-provide="typeahead"/>

 

 

and controller

 

public function localizaprodutos(){

                        

                        $this->autoRender = false;

        $this->RequestHandler->respondAs('json');

 

        // get the search term from URL

        $term = $this->request->query['q'];

        $users =
$this->Invoice->Invoicedetail->Inventoryitem->find('all',array(

            'conditions' => array(

                'Inventoryitem.desc LIKE' => '%'.$term.'%'

            )

        ));

 

        // Format the result for select2

        $result = array();

        foreach($produtos as $key => $produto) {

            array_push($result, $produto['Inventoryitem']['desc']);

        }

        $produtos = $result;

        

        echo json_encode($produtos);

    }

 

 

Thanks

 

Renato

 

 

 

 

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
--- 
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.

<<image001.jpg>>

Reply via email to