This is an old revision of the document!
abstract public function run() This function should implement the logic of the view. protected function redirect($url, $status_code=302) This function performs a redirect to the provided url.
TemplateView extends View.
run()run_exception($exception):run_form($form)run_page()$this→template is set, return that.$view_name is set, return “[$base_name]_[view_name].phtml”.“[$base_name].phtml”.
Where $base_name defaults to “template_[$this→page_id]” but can be overriden by setting the $template_base_name property.
protected $page_id String used to identify the template name and the page titleprotected $template Contains the view's form, but obsolete if you override get_form().protected $template_base_name Contains the view's success_url, but obsolete if you override get_succes_url() or run_form_valid().protected $title Contains a human readable page title.
TemplateView inherits all functions from View. It implements run().
public function __construct($page_id, $title=“”)public function run() This function runs the logic of the view. It should not be overridden, as it makes sure exceptions are correctly rendered. If you want to customize how views are executed, you should override run_page().protected function run_page()protected function run_exception($e)protected function render_template($template, array $context=[]) Renders a template with context. Merges in the default context.protected function get_default_context() Returns the default context. The default implementation returns the view's $title and $page_id.protected function get_template($view_name=“”)
FormView extends TemplateView .
run()run_page()run_form($form)run_form_valid($form)process_form_data($data)run_form_invalid($form)
FormView inherits all properties from TemplateView.
protected $form Contains the view's form, but obsolete if you override get_form().protected $success_url Contains the view's success_url, but obsolete if you override get_succes_url() or run_form_valid().
FormView inherits all functions from TemplateView. It implements run_page().
protected function run_form($form) It is not recommended to override this function if you want to customize form handling. Override form_valid() and form_invalid instead.protected function form_valid($form)protected function form_invalid($form)abstract protected function process_form_data($data) This function should implement the logic used to process the form data. The $data variable is an associated array containing field_name ⇒ value pairs.protected function get_form()protected function get_success_url()