Class FormProcessor

Description

This is the main engine for the processing

of Forms. It builds the form tag, and calls the appropriate FormContent methods to build the FormElement's and validation, as well as backend processing to do the action after the data has been validated.

Located in /form/FormProcessor.inc (line 31)

Container
   |
   --FormProcessor
Direct descendents
Class Description
FormWizard This is a magic container that allows you to chain together multiple FormContent objects to automatically create a Wizard process.
Variable Summary
Method Summary
FormProcessor FormProcessor (FormContent &$form_content, [string $form_name = "myform"], [ $form_action = NULL])
BOOLEAN can_validate ()
void do_validation ()
string get_action ()
array get_error_array ()
string get_form_action ()
string get_form_enctype ()
string get_form_method ()
string get_form_name ()
string get_form_target ()
string get_onsubmit ()
boolean has_errors ()
void render ([ $indent_level = 0], [ $output_debug = 0])
string render_confirm (int $indent_level, int $output_debug)
raw render_error (array $indent_level, array $output_debug, int 2, int 3)
raw render_form ( $indent_level, int $output_debug, [int $obj = NULL], the FormContent->form(), object - 3)
void set_auto_error_display ([boolean $flag = TRUE])
void set_form_action (string $action)
void set_form_attribute (string $key, string $value)
void set_form_enctype (string $enctype)
void set_form_method (string $method)
void set_form_name (string $name)
void set_form_target (string $target)
none set_onsubmit (string $js)
void set_render_form_after_success ([ $flag = TRUE])
string _build_javascript ()
void _pre_confirm ()
void _process_action ()
void _process_form ()
void _set_action ()
void _set_confirmed_success ([boolean $flag = TRUE])
void __hidden_fields ()
Variables
mixed $_auto_show_errors = TRUE (line 99)

This tells us to show or not to show the form errors autmatically.

The user of the FormProcessor may want to deal with errors manually

mixed $_confirmed = FALSE (line 65)

Flag to let us know the form has been confirmed.

mixed $_confirmed_successful = FALSE (line 91)

The form was processed and passed

the confirmation if any, and it was successfull ?

mixed $_FormValidation = NULL (line 78)

This is the FormValidation object

used to validate the form elements

mixed $_form_attributes = array("method" => "post",
"action" => "",
"name" => "myform",
"target" => "",
"onsubmit" => "",
"style" => "margin: 0px 0px 0px 0px;")
(line 39)

This array holds the FORMtag

attributes for this form

mixed $_form_content = NULL (line 51)

This holds the FormContent Object that knows how to render the form.

mixed $_form_submit_action = NULL (line 84)

The action that was taken

for the form

mixed $_form_success_render = TRUE (line 72)

Flag to let us know if we should

render the form after it was successfully processed

mixed $_has_errors = FALSE (line 59)

This flag lets us know there were errors during processing or validating the form.

Methods
Constructor FormProcessor (line 108)

The constructor for the FormProcessor

FormProcessor FormProcessor (FormContent &$form_content, [string $form_name = "myform"], [ $form_action = NULL])
  • FormContent &$form_content: object
  • string $form_name: the form name
  • $form_action
can_validate (line 417)

This method lets us turn on/off the ability to do validation for the form

BOOLEAN can_validate ()
do_validation (line 240)

This method walks the FormContent's visible elements

and calls the validation function for the element

void do_validation ()
get_action (line 643)

This is used to get the action that was processed by the form

string get_action ()
get_auto_error_display (line 474)

This gets the current value of the flag that tells us to show form errors automatically or not.

boolean get_auto_error_display ()
get_error_array (line 503)

This method returns an array of errors that happened in the form.

array get_error_array ()
get_error_display_object (line 488)

This method allows us to get access to the errors display object that is generated by the form content. This is the display object that is meant to be rendered directly.

If there are no errors. we will return NULL

object &get_error_display_object ()
get_form_action (line 603)

This function is used to get the form action

  • return: (POST or GET)
string get_form_action ()
get_form_enctype (line 622)

This function is used to get the form enctype value

string get_form_enctype ()
get_form_method (line 584)

This function is used to get the form method

  • return: (POST or GET)
string get_form_method ()
get_form_name (line 540)

This function is used to get the form name

string get_form_name ()
get_form_target (line 560)

This function is used to get the form target

string get_form_target ()
get_onsubmit (line 667)

Gets the current value of the form tag's onsubmit value

string get_onsubmit ()
has_errors (line 513)

This returns the flag that tells us that the form has errors during processing

boolean has_errors ()
is_action_successful (line 441)

This is used to test to see if the form action was processed succesfully.

This is usefull for external entities to determine if the form was processed, and it was successful.

boolean is_action_successful ()
render (line 262)

This method is called to render the form's html

void render ([ $indent_level = 0], [ $output_debug = 0])
  • $indent_level
  • $output_debug

Redefinition of:
Container::render()
This function is compatible with the rest of the phpHtmllib API spec.

Redefined in descendants as:
render_confirm (line 359)

This function renders the confirmation page. This page sits in between the front end form, and the action handler.

This only gets called after a form and its data has been successfully validated.

  • return: - the raw html
string render_confirm (int $indent_level, int $output_debug)
  • int $indent_level: - $indent_level
  • int $output_debug: - $output_debug

Redefined in descendants as:
  • FormWizard::render_confirm() : This function renders the confirmation page. This page sits in between the front end form, and the action handler.
render_error (line 388)

This renders the error table and then the form with the fields

  • return: html
raw render_error (array $indent_level, array $output_debug, int 2, int 3)
  • int 2: - $indent_level
  • int 3: - $output_debug
  • array $indent_level: - the form field vlues.
  • array $output_debug: - array of errors.
render_form (line 308)

This renders the form

  • return: html
raw render_form ( $indent_level, int $output_debug, [int $obj = NULL], the FormContent->form(), object - 3)
  • the FormContent->form(): object
  • object - 3: the form errors object.
  • int $output_debug: - $indent_level
  • int $obj: - $output_debug
  • $indent_level
setup_validation (line 140)

This function is used to setup the validation object and the form errors object that is to be used by this form.

You can override this method to use a different FormErrors object for localization.

void setup_validation ()

Redefined in descendants as:
set_auto_error_display (line 463)

This sets the flag that tells this class to automatically call the form contents form errors and display it or not

void set_auto_error_display ([boolean $flag = TRUE])
  • boolean $flag: - show errors?
set_form_action (line 593)

Sets the form action

void set_form_action (string $action)
  • string $action
set_form_attribute (line 680)

Set a random attribute on the form tag.

You should know what you are doing as this might invalidate the output html with the W3C validator.

void set_form_attribute (string $key, string $value)
  • string $key: the key
  • string $value: the value
set_form_enctype (line 612)

Sets the form enctype

void set_form_enctype (string $enctype)
  • string $enctype
set_form_method (line 570)

This function is used to set the form method

void set_form_method (string $method)
  • string $method: (POST or GET)
set_form_name (line 530)

This function is used to set the form name

void set_form_name (string $name)
  • string $name
set_form_target (line 550)

This function is used to set the form target

void set_form_target (string $target)
  • string $target
set_onsubmit (line 657)

Set the onsubmit attribute to the form NOTE: The FormContent child can automatically set this value depending on the FormElement children it contains.

none set_onsubmit (string $js)
  • string $js
set_render_form_after_success (line 429)

This function turns on the ability to

render the form after the success of the action. Normally this feature is off

void set_render_form_after_success ([ $flag = TRUE])
  • $flag
_add_confirm_data (line 763)

This adds all of the submitted data as

hidden form fields

void _add_confirm_data ()
_add_hidden_fields (line 785)

This function adds the form content's

hidden form fields to the form automatically

void _add_hidden_fields ()
_build_form_tag (line 720)

this function builds the FORMtag object and its attributes.

  • return: object.
FORMtag _build_form_tag ()

Redefined in descendants as:
  • FormWizard::_build_form_tag() : Override this so that we can place the toolbar first inside the form tag. We also have to make sure the onsubmit stuff is working properly.
_build_javascript (line 821)

This method is used to build any Javascript that is used by the form and/or the form elements used in the form.

string _build_javascript ()
_init_form_content (line 695)

This method initializes the FormContent during processing.

none _init_form_content ()
_pre_confirm (line 220)

This method calls the FormContent

to let it do any data munging before the confirmation page is rendered

void _pre_confirm ()
_process_action (line 210)

This function is responsible for processing the form action after validation, and form confirmation happens.

void _process_action ()
_process_form (line 149)

This method does the logic of

doing the form processing

void _process_form ()

Redefined in descendants as:
_set_action (line 632)

This is used to set the action

submitted by the user

void _set_action ()
_set_confirmed_success (line 452)

This flag sets the flag that tells if we successfully confirmed the form, and processed the action

void _set_confirmed_success ([boolean $flag = TRUE])
  • boolean $flag
__hidden_fields (line 798)

This method adds the processor specific hidden fields.

void __hidden_fields ()

Redefined in descendants as:

Inherited Methods

Inherited From Container

Container::Container()
Container::add()
Container::add_reference()
Container::count_content()
Container::get_element()
Container::get_indent_flag()
Container::push()
Container::push_reference()
Container::render()
Container::reset_content()
Container::set_collapse()
Container::set_indent_flag()

Documentation generated on Fri, 28 Jan 2011 08:53:07 -0500 by phpDocumentor 1.4.3