pnForm
[ class tree: pnForm ] [ index: pnForm ] [ all elements ]

Class: pnFormHandler

Source Location: /includes/pnForm.php

Class Overview


Base form handler class


Methods



Class Details

[line 1046]
Base form handler class

This is the base class to inherit from when creating your own form handlers.

Member variables in a form handler object is persisted accross different page requests. This means a member variable $this->X can be set on one request and on the next request it will still contain the same value.

A form handler will be notified of various events that happens during it's life-cycle. When a specific event occurs then the corresponding event handler (class method) will be executed. Handlers are named exactly like their events - this is how the framework knows which methods to call.

The list of events is:

  • initialize: this event fires before any of the events for the plugins and can be used to setup the form handler. The event handler typically takes care of reading URL variables, access control and reading of data from the database.
  • handleCommand: this event is fired by various plugins on the page. Typically it is done by the pnFormButton plugin to signal that the user activated a button.




[ Top ]


Class Methods


method handleCommand [line 1091]

void handleCommand( &$render, &$args)

Command event handler

This event handler is called when a command is issued by the user. Commands are typically something that originates from a pnFormButton plugin. The passed args contains different properties depending on the command source, but you should at least find a $args['commandName'] value indicating the name of the command. The command name is normally specified by the plugin that initiated the command.




Tags:



Parameters:

   &$render  
   &$args  

[ Top ]

method initialize [line 1075]

bool initialize( &$render)

Initialize form handler

Typical use:

  1.  function initialize(&$render)
  2.  {
  3.    if (!HasAccess// your access check here
  4.       return $render->pnFormSetErrorMsg('No access');
  5.  
  6.    $id FormUtil::getPassedValue('id');
  7.  
  8.   $data pnModAPIFunc('MyModule''user''get',
  9.                        array('id' => $id));
  10.    if (count($data== 0)
  11.      return $render->pnFormSetErrorMsg('Unknown data');
  12.  
  13.    $render->assign($data);
  14.  
  15.    return true;
  16.  }




Tags:

return:  False in case of initialization errors, otherwise true. If false is returned then the framework assumes that pnFormRender::pnFormSetErrorMsg() has been called with a suitable error message.


Parameters:

   &$render  

[ Top ]


Documentation generated on Fri, 18 Jul 2008 21:52:54 +0200 by phpDocumentor 1.4.1