Monday, June 30, 2008

Interacting with your Views

Interacting with your views:

set($variable, $value);
string $variable;
mixed $value;

The principal use of this function is to extract data from a controller and transfer it to a view.
It can be used to transfer single values, whole arrays and so on etc. The moment you utilize set(), the variable can be accessed in your view: doing set(name, john) in your controller makes the variable name available in the view.

validateErrors() - displays the number of all the errors produced by an unsuccessful save.
validate() - this function is used to validate a model data respecting the rules of validation defined in to the model.

render($action, $layout, $file) - this function may not always be needed because render is called by default when every controller action ends, so the view specific to your action is rendered. On the other side, you can call this function to render the view anywhere in the controller code.

No comments: