zen of coding

Food for thought: $this->redirect() vs $this->render()

One example, that we often see, is something along the following lines in the controller: if($this->User->save($this->data)) {   $this->Session->setFlash(… some stuff for the view … );   $this->redirect(array(’action’=>’success’)); } If all we are doing is displaying a “success” page back to the user, do we really need to bother with[…]

Read More »

Food for thought: $this->redirect() vs $this->render()

One example, that we often see, is something along the following lines in the controller: if($this->User->save($this->data)) {   $this->Session->setFlash(… some stuff for the view … );   $this->redirect(array(’action’=>’success’)); } If all we are doing is displaying a “success” page back to the user, do we really need to bother with[…]

Read More »

Set::merge() and dynamic validation rules

Here’s another trick with Set::merge()… Let’s say we’ve defined some basic validation rules in our Profile model, something like: var $validate = array (    ‘name’ => array(       ‘rule’ => array(’notEmpty’),       ‘required’ => false,       ‘message’ => ‘Please enter a name’  […]

Read More »
%d bloggers like this: