Never been to CodeSnippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)

A scaffolding input for multple checkboxes with habtm

We have mutiple conditions, which are habtm to

echo "<!--{$form->input('Condition')}-->";
        if(is_array($conditions)){
        foreach($conditions as $condition => $title){
            print $title . "<input type='checkbox' value='{$condition}' name='data[Profile][Profile][]'>". "\n";
            }
        } 

Automatic Pagination

// description of your code here
Automatic Pagination:
(using model bankBranches with fields 'name' and 'bank_id')
var $paginate = array('order' =>array('name' => 'asc')); //paginate by name

OR

$this->set('bankBranches', $this->paginate('BankBranch.bank_id')); //paginate by bank_id


Sometimes one works, and sometimes the other one works...