Table of Contents

Views

Abstract: View

Functions

TemplateView

TemplateView extends View.

Pipelines

Running the view

  1. run()
  2. if exception: run_exception($exception):
    1. renders error template
  3. run_form($form)
  4. else: run_page()
    1. renders page template

Resolving a template name

  1. If $this->template is set, return that.
  2. If $view_name is set, return '[base_name]_[view_name].phtml'.
  3. Else return '[base_name].phtml'.

Where $base_name defaults to 'template_[page_id]' but can be overriden by setting the $template_base_name property.

Properties

Functions

TemplateView inherits all functions from View. It implements run().

Abstract: FormView

FormView extends TemplateView.

Pipelines

Running the view

  1. run()
  2. run_page()
  3. run_form($form)
  4. if form validates: run_form_valid($form)
    1. process_form_data($data)
    2. redirects to succes_url
  5. else: run_form_invalid($form)
    1. renders form

Properties

FormView inherits all properties from TemplateView.

Functions

FormView inherits all functions from TemplateView. It implements run_page().

ModelView

ModelView extends FormView.

Pipelines

Running the view

  1. run()
  2. run_page()
  3. if view = create: run_create()
    1. get_form()
    2. run_form($form) according to FormView pipeline
  4. if view = read: run_read()
    1. get_object()
    2. renders template for view = read with context variable 'object'
  5. if view = update: run_update()
    1. get_form()
    2. populate form with get_object()
    3. run_form($form) according to FormView pipeline
  6. if view = delete: run_delete()
    1. if request method = POST
      1. delete object
      2. redirect to success url
    2. else
      1. renders template for view = delete with context variable 'object'
  7. if view = list: run_list()
    1. renders template for view = list with context variable 'objects'

Properties

ModelView inherits all properties from FormView.

Functions

ModelView inherits all functions from FormView. It implements process_form_data() and overrides __construct(), run_page(), get_success_url() and get_template().