Skip to main content

Posts

Showing posts from June, 2014

Cakephp Containable Behaviour

Containable Behavior This model behavior allows you to filter and limit model find operations.Containable allows you to streamline and simplify operations on your model bindings. It works by temporarily or permanently altering the associations of your models. To use the new behavior, you can add it to the $actsAs property of your model: class Post extends AppModel {     public $actsAs = array ( 'Containable' ); } You can also attach the behavior on the fly: $this -> Post -> Behaviors -> load ( 'Containable' ); You can also invoke Containable’s magic from inside the find() call: $this -> Post -> find ( 'all' , array ( 'contain' => false ));   $this -> Post -> find ( 'all' , array ( 'contain' => 'Comment.author' ));   You can also filter the associated Comment data by specifying a condition: $this -> Post -> find ( 'all' , array ( 'contain&

Model Validation in Cakephp

Server Side Model Validation in cakephp Step 1:  Create a form in in view  View  <div class="users form"> <?php echo $this->Form->create('User');?>     <fieldset>  <legend><?php echo __('Add User'); ?></legend>         <?php echo $this->Form->input('username'); echo $this->Form->input('email');  echo $this->Form->input('password'); echo $this->Form->input('password_confirm', array('label' => 'Confirm Password *', 'maxLength' => 255, 'title' => 'Confirm password', 'type'=>'password')); echo $this->Form->input('role', array( 'options' => array( 'king' => 'King', 'queen' => 'Queen', 'rook' => 'Rook', 'bishop' => 'Bishop', 'knight' => 'Knight