Class: I2CE PageForm
This article desrcibes the1 class I2CE_PageForm which extends the class I2CE_Page It is contained in the module forms in the package I2CE
The class is defined in the file: modules/Forms/lib/I2CE_PageForm.php
Handles all page display and operations for forms. This class extends the {@link I2CE_Page} class and adds some default methods and variables for form templates that will interface with a {@link I2CE_Form} object to update the database. The {@link loadObjects()} method must be overwritten for all objects extending this abstract class. @abstract
- Author: Luke Duncan <lduncan@intrahealth.org>
- Since: v1.0.0
- See: I2CE_Template
Constants
I2CE_PageForm::EDIT_PRIMARY
Constant values for the type of object being set to be edited for this page: Primary
The primary object is the main object being edited by this page. There can only be one.
Defined as: 1
I2CE_PageForm::EDIT_PARENT
Constant values for the type of object being set to be edited for this page: Parent
The parent for the primary and secondary objects being edited by this page. The can only be one.
Defined as: 2
I2CE_PageForm::EDIT_SECONDARY
Constant values for the type of object being set to be edited for this page: Secondary
Any secondary objects being edited by this page. They share the parent of the primary. Multiple objects can be added.
Defined as: 3
I2CE_PageForm::EDIT_CHILD
Constant values for the type of object being set to be edited for this page: Children
Any child objects of the primary object will use this type. Multiple objects can be added.
Defined as: 4
Variables
$objects
The objects related to this page. Using the PAGE_FORM_EDIT constants to determine the key for the array and the values will either be a {@link I2CE_Form} or an array of {@link I2CE_Form}s.
- Type: protected y $objects
$node_ids
The node id's of objects related to this page.
- Type: protected y $node_ids
$editing
A flag to determine if the page is being edited for the dynamic lists.
- Type: private n $editing
$factory
The factory object that creates new instances of forms
- Type: protected I2CE_FormFactory $factory
$usesConfimPage
@var protected boolean $usesConfirmPage
- Type: protected $usesConfimPage
$formAttributes
an associative array of attributes to set for the form
- Type: protected y $formAttributes
Methods
__construct()
Create a new instance of a form page.
This will call the constructor for all Page objects and then set up some additional member variables for forms. @param string $title The title for this page. @param string $defaultHTMLFile The default HTML file for this page. @param mixed $access The role required to access this page. @param array $files The list of template files to load for this page.
- Signature: public function __construct($args,$request_remainder,$get,$post)
Parameters:
- $args
- $request_remainder
- $get
- Default Value: null
- $post
- Default Value: null
action()
Perform the actions of the page.
The default method sets up a form object to display the form and confirmation pages for the given object. It handles everything necessary for editing and saving a single object. Some forms may need to override this if the actions are more complex. Or more simple.
- Signature: protected function action()
displayControls()
Display the save or confirm buttons as needed.
If the page is a confirmation view then the save / edit button template will be displayed. Otherwise the confirm and return buttons will be shown. @global array
- Signature: protected function displayControls($save,$show_edit)
Parameters:
- boolean $save
Flag to show the save button. (Defaults to false)- Default Value: false
- boolean $show_edit
(defaults to true)- Default Value: true
getParent()
Return the parent object for this form.
- Signature: protected function getParent()
- Returns: I2CE_Form
getPrimary()
Return the primary object being edited.
- Signature: protected function getPrimary()
- Returns: I2CE_Form
hasInvalid()
Checks to see if any of the forms on this page have invalid messages
- Signature: public function hasInvalid()
- Returns: boolean
invalidMessage()
Add the form_error template to the page if the template is marked as invalid.
- Signature: public function invalidMessage()
isConfirm()
Checks to see if the page is a confirmation page.
- Signature: protected function isConfirm($validate)
- Returns: boolean
Parameters:
- $validate
- Default Value: true
isEdit()
Checks to see if the page is being submitted as an edit operation.
- Signature: protected function isEdit($validate)
- Returns: boolean
Parameters:
- boolean $validate
Flag to also check to be sure the form data is valid.- Default Value: true
isEditing()
Check to see if this page is an editing page and already has data populated.
- Signature: final protected function isEditing()
- Returns: boolean;
isSave()
Checks to see if the page is being submitted as a save operation.
- Signature: protected function isSave($validate)
- Returns: boolean
Parameters:
- boolean $validate
Flag to also check to be sure the form data is valid.- Default Value: true
loadObjects()
Create and load any necessary objects for this form.
This method must be written for each class extending this class.
- Signature: protected function loadObjects()
save()
Save the objects to the database.
Save the default object being edited b @global array
- Signature: protected function save()
setDisplayData()
Set the data to be displayed for the outside of the form field elements.
Set up the static data to be displayed in the template. The default method doesn't do anything, but sub-classes may need to override this method.
- Signature: protected function setDisplayData()
setEditing()
Set this page to be an editing page for the dynamic lists.
- Signature: final protected function setEditing()
setForm()
Set the I2CE_Form object in the page template.
This method will pass the edit object to the page template so that it can process all the form variables.
- Signature: protected function setForm()
setFormAttributes()
Set any attributes for the form attributes, values are values.
- Signature: public function setFormAttributes($formAttributes)
Parameters:
- array $formAttributes
an associative array of attributes to set for the form. Keys are
setObject()
Add an object to the objects being edited or displayed by this page. Defaults to null meaning that it applies to the whole page
- Signature: final protected function setObject($object,$type,$node_id)
Parameters:
- I2CE_Form $object
- integer $type
The type of object being added from EDIT constants.- Default Value: self::EDIT_PRIMARY
- mixed $node_id
a tring which gives the node id for which this object applies to. also can be the DOMNode.- Default Value: null
usesConfirmPage()
Set whether or not we use the confirm page when submitting the form
- Signature: public function usesConfirmPage($val)
Parameters:
- boolean $val
True if we use a confirm page
validate()
Run the validation methods for all the objects being edited.
If this is a form submit then run the validation methods for the default object being edited. The default method calls the {@link I2CE_Form::validate() validate} method on the {@link $edit_obj} object.
- Signature: protected function validate()
Inherited Variables
$template
Theis protected variable is inherited from I2CE_Page->$template
$defaultHTMLFile
Theis protected variable is inherited from I2CE_Page->$defaultHTMLFile
$role
Theis protected variable is inherited from I2CE_Page->$role
$user
Theis protected variable is inherited from I2CE_Page->$user
$post
Theis protected variable is inherited from I2CE_Page->$post
$get
Theis protected variable is inherited from I2CE_Page->$get
$page_root
Theis protected variable is inherited from I2CE_Page->$page_root
$page_remainder
Theis protected variable is inherited from I2CE_Page->$page_remainder
$args
Theis protected variable is inherited from I2CE_Page->$args
$request_remainder
Theis protected variable is inherited from I2CE_Page->$request_remainder
$permissionParser
Theis protected variable is inherited from I2CE_Page->$permissionParser
$page
Theis protected variable is inherited from I2CE_Page->$page
$module
Theis protected variable is inherited from I2CE_Page->$module
$is_post
Theis protected variable is inherited from I2CE_Page->$is_post
$session_req
Theis protected variable is inherited from I2CE_Page->$session_req
Inherited Fuzzy Methods
launchBackgroundProcess()
This method is inherited from I2CE_Page->launchBackgroundProcess()
launchBackgroundPHPScript()
This method is inherited from I2CE_Page->launchBackgroundPHPScript()
launchBackgroundPage()
This method is inherited from I2CE_Page->launchBackgroundPage()
addColorPickerTriple()
This method is inherited from I2CE_Page->addColorPickerTriple()
selectOptionsImmediate()
This method is inherited from I2CE_Page->selectOptionsImmediate()
setDisplayData()
This method is inherited from I2CE_Page->setDisplayData()
setDisplayDataImmediate()
This method is inherited from I2CE_Page->setDisplayDataImmediate()
addFormWorm()
This method is inherited from I2CE_Page->addFormWorm()
getClassValue()
This method is inherited from I2CE_Page->getClassValue()
loadClassValues()
This method is inherited from I2CE_Page->loadClassValues()
setClassValue()
This method is inherited from I2CE_Page->setClassValue()
setClassValues()
This method is inherited from I2CE_Page->setClassValues()
addOption()
This method is inherited from I2CE_Page->addOption()
addOptions()
This method is inherited from I2CE_Page->addOptions()
addAutoCompleteInputTreeById()
This method is inherited from I2CE_Page->addAutoCompleteInputTreeById()
addAutoCompleteInputTree()
This method is inherited from I2CE_Page->addAutoCompleteInputTree()
setForm()
This method is inherited from I2CE_Page->setForm()
getField()
This method is inherited from I2CE_Page->getField()
setReview()
This method is inherited from I2CE_Page->setReview()
isReview()
This method is inherited from I2CE_Page->isReview()
setShowForm()
This method is inherited from I2CE_Page->setShowForm()
showForm()
This method is inherited from I2CE_Page->showForm()
makeJumper()
This method is inherited from I2CE_Page->makeJumper()
This method is inherited from I2CE_Page->menuSelect()
addUpdateSelect()
This method is inherited from I2CE_Page->addUpdateSelect()
addAjaxUpdate()
This method is inherited from I2CE_Page->addAjaxUpdate()
addAjaxToggle()
This method is inherited from I2CE_Page->addAjaxToggle()
addAjaxRequestFunction()
This method is inherited from I2CE_Page->addAjaxRequestFunction()
addAjaxCompleteFunction()
This method is inherited from I2CE_Page->addAjaxCompleteFunction()
addAjaxToggleOnFunction()
This method is inherited from I2CE_Page->addAjaxToggleOnFunction()
addAjaxToggleOffFunction()
This method is inherited from I2CE_Page->addAjaxToggleOffFunction()
hasAjax()
This method is inherited from I2CE_Page->hasAjax()
setDataTypePriority()
This method is inherited from I2CE_Page->setDataTypePriority()
setData()
This method is inherited from I2CE_Page->setData()
getData()
This method is inherited from I2CE_Page->getData()
getDefaultData()
This method is inherited from I2CE_Page->getDefaultData()
removeData()
This method is inherited from I2CE_Page->removeData()
getDataNames()
This method is inherited from I2CE_Page->getDataNames()
ensureNode()
This method is inherited from I2CE_Page->ensureNode()
userMessage()
This method is inherited from I2CE_Fuzzy->userMessage()