Back to top

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revisionBoth sides next revision
documentation:rack:reference:views [2018/05/25 19:31] Martijn Luinstradocumentation:rack:reference:views [2018/05/26 16:37] Martijn Luinstra
Line 4: Line 4:
  
 ==== Functions ==== ==== Functions ====
-  * <php>abstract public function run()</php> This function should implement the logic of the view.  +  * <php>abstract run()</php> This function should implement the logic of the view.  
-  * <php>protected function redirect($url, $status_code=302)</php> This function performs a redirect to the provided url.+  * <php>protected redirect($url, $status_code=302)</php> This function performs a redirect to the provided url.
  
  
Line 40: Line 40:
 <php>TemplateView</php> inherits all functions from <php>View</php>. It implements <php>run()</php>. <php>TemplateView</php> inherits all functions from <php>View</php>. It implements <php>run()</php>.
  
-  * <php>public function __construct($page_id, $title='')</php> +  * <php>__construct($page_id, $title='')</php> 
-  * <php>public function run()</php> 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 <php>run_page()</php>+  * <php>run()</php> 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 <php>run_page()</php>
-  * <php>protected function run_page()</php> +  * <php>protected run_page()</php> 
-  * <php>protected function run_exception($e)</php> +  * <php>protected run_exception($e)</php> 
-  * <php>protected function render_template($template, array $context=[])</php> Renders a template with context. Merges in the default context.+  * <php>protected render_template($template, array $context=[])</php> Renders a template with context. Merges in the default context.
   * <php>protected function get_default_context()</php> Returns the default context. The default implementation returns the view's <php>$title</php> and <php>$page_id</php>.   * <php>protected function get_default_context()</php> Returns the default context. The default implementation returns the view's <php>$title</php> and <php>$page_id</php>.
   * <php>protected function get_template($view_name='')</php>   * <php>protected function get_template($view_name='')</php>
Line 76: Line 76:
 <php>FormView</php> inherits all functions from <php>TemplateView</php>. It implements <php>run_page()</php>. <php>FormView</php> inherits all functions from <php>TemplateView</php>. It implements <php>run_page()</php>.
  
-  * <php>protected function run_form($form)</php> It is not recommended to override this function if you want to customize form handling. Override <php>form_valid()</php> and <php>form_invalid()</php> instead. +  * <php>protected run_form($form)</php> It is not recommended to override this function if you want to customize form handling. Override <php>form_valid()</php> and <php>form_invalid()</php> instead. 
-  * <php>protected function form_valid($form)</php> +  * <php>protected form_valid($form)</php> 
-  * <php>protected function form_invalid($form)</php> +  * <php>protected form_invalid($form)</php> 
-  * <php>abstract protected function process_form_data($data)</php> This function should implement the logic used to process the form data. The <php>$data</php> variable is an associated array containing //field_name// => //value// pairs. +  * <php>abstract protected process_form_data($data)</php> This function should implement the logic used to process the form data. The <php>$data</php> variable is an associated array containing //field_name// => //value// pairs. 
-  * <php>protected function get_form()</php> +  * <php>protected get_form()</php> 
-  * <php>protected function get_success_url()</php>+  * <php>protected get_success_url()</php>
  
  
Line 125: Line 125:
 <php>ModelView</php> inherits all functions from <php>FormView</php>. It implements <php>process_form_data()</php> and overrides <php>__construct()</php>, <php>run_page()</php>, <php>get_success_url()</php> and <php>get_template()</php>. <php>ModelView</php> inherits all functions from <php>FormView</php>. It implements <php>process_form_data()</php> and overrides <php>__construct()</php>, <php>run_page()</php>, <php>get_success_url()</php> and <php>get_template()</php>.
  
-  * <php>public function __construct($page_id, $title='', $model=null, $form=null)</php> +  * <php>public __construct($page_id, $title='', $model=null, $form=null)</php> 
-  * <php>protected function run_page()</php> It is not recommended to override this function unless you want to create additional views. Override <php>run_create()</php>, <php>run_read()</php>, <php>run_update()</php>, <php>run_delete()</php> and <php>run_list()</php> instead. +  * <php>protected run_page()</php> It is not recommended to override this function unless you want to create additional views. Override <php>run_create()</php>, <php>run_read()</php>, <php>run_update()</php>, <php>run_delete()</php> and <php>run_list()</php> instead. 
-  * <php>protected function run_create()</php> +  * <php>protected run_create()</php> 
-  * <php>protected function run_read()</php> +  * <php>protected run_read()</php> 
-  * <php>protected function run_update()</php> +  * <php>protected run_update()</php> 
-  * <php>protected function run_delete()</php> +  * <php>protected run_delete()</php> 
-  * <php>protected function run_list()</php> +  * <php>protected run_list()</php> 
-  * <php>protected function process_form_data($data)</php> Creates or updates object in database. +  * <php>protected process_form_data($data)</php> Creates or updates object in database. 
-  * <php>protected function get_model()</php> +  * <php>protected get_model()</php> 
-  * <php>protected function get_object()</php> +  * <php>protected get_object()</php> 
-  * <php>protected function get_success_url()</php> Overridden to redirect to the default view. +  * <php>protected get_success_url()</php> Overridden to redirect to the default view. 
-  * <php>protected function get_template($view_name='')</php> Overridden to render the template for the active view if <php>$view_name</php> is not provided.+  * <php>protected get_template($view_name='')</php> Overridden to render the template for the active view if <php>$view_name</php> is not provided.
  

documentation/rack/reference/views.txt · Last modified: 2023/08/31 23:22 by Martijn Luinstra