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

Class: PtcForms

Source Location: /PhpToolCase/current/PtcForms.php

Class PtcForms

Property Summary
bool   $_buildHidden   build hidden values parameter
array   $_defaultOptions   default options
mixed   $_elAttributes   Html attributes for all elements
integer   $_elRandId   autogenerate an id for the element if not given
array   $_formFields   fields storage
array   $_hiddenValues   auto generated hidden fields storage
array   $_htmlTpls   html templates
array   $_storageKeys   possibile options in fields storage
array   $_validate   array of fields to validate

[ Top ]
Method Summary
PtcForms   __construct()   Set form method(POST,GET) and start the engine to keep sent values
void   addField()   Add input field to the object
void   addFieldAttributes()   Add attributes to input field
void   addFieldEvent()   Alias of addFieldEvents()
void   addFieldEvents()   Add events to input field
void   addFieldLabel()   Add a label text for the input field
void   addFieldValidator()   Add validator for input field
void   addFieldValue()   Alias of addFieldValues()
void   addFieldValues()   Add values to input fields
void   addLabelOptions()   Add attributes to the label
void   addSpacer()   Add spacer div
void   addValuesParams()   Add paramaters to field values group
void   customElAttributes()   Manipulate/Add html elements attributes
void   customTpl()   Alias of customTpls()
void   customTpls()   Manipulate html templates
void   fieldParentEl()   Add attributes to div container for input field
void   removeField()   Remove field(under development)
void   renderField()   Render field
void   renderForm()   Render form
void   validateEmail()   Check if value is valid email
void   validateEqualTo()   Check if value matches other field value
returns   validateForm()   Validate form fields defined with the addFieldValidator() method
void   validateNumber()   Check if value is numeric
void   validatePattern()   Check if given regex pattern is matched
void   validateRequired()   Check if value is empty
void   validator()   Alias of validateForm()
void   _addClassValidator()   Add validator classes to field for js validation
void   _addCompositeField()   Add composite for multiple layouts with html table
void   _addDefaultValues()   Add empty default values when addField() is called
void   _addFieldParams()   Add parameters to field
void   _addInputStyle()   Add default style to field to align properly
void   _addLabelStyle()   Add default style to label to align properly
void   _addTableStyle()   Add default style to table to align properly
void   _addValidator()   Add validator to input field
void   _buildAttributes()   Build attributes for html elements
void   _buildContainer()   Build container for field
void   _buildElAttributes()   Replace $_elAttributes with template {attributes}
void   _buildField()   Build fields
void   _buildHtml()   Build container for field
void   _buildLabel()   Build label for field
void   _buildList()   Build html select options
void   _buildTableData()   Build dynamic table for multiple layouts
void   _checkErrors()   Check for errors while building or rendering the form
void   _editMethod()   Change values in form method(POST,GET)
void   _rebuildValues()   Rebuild values for fields if POST or GET
void   _switchLabelEl()   Switch between span and label elements according to field type
void   _useMethod()   Retrieve form method(POST,GET)

[ Top ]
Properties
bool   $_buildHidden = true [line 1221]

build hidden values parameter

API Tags:
Access:  private


[ Top ]
array   $_defaultOptions = array
(
"form_method" => "post", # the form method to use
"form_action" => "#", # the form action url
"form_width" => "500px", # the width for the main container
"add_class_validator" => false, # add validator classes to fields for use with jquery
"labels_align" => "left", # align labels globally(left,top,right)
"labels_width" => "40%", # the width for labels as a percentage
"style_elements" => true, # add default style to input elements to align properly
"style_labels" => true, # add default style to label elements to align properly
"style_tables" => true, # add default style to table elements to align properly
"spacer_height" => "3px", # height for the spacer between fields
"keep_values" => true, # repopulate filled fields on form submission
"print_form" => true, # print form to screen or return html only
"start_tab" => "\t", # format html code with tabs
"err_msg_level" => E_USER_WARNING,# error messages level
)
[line 370]

default options

API Tags:
Access:  protected


[ Top ]
mixed   $_elAttributes = array('class','id','style','value','maxlength','size','disabled','checked','target',
'events','title','selected','cols','rows','equalTo','border','pattern','cellpadding','cellspacing')
[line 411]

Html attributes for all elements

API Tags:
Access:  protected


[ Top ]
integer   $_elRandId [line 437]

autogenerate an id for the element if not given

API Tags:
Access:  protected


[ Top ]
array   $_formFields = array() [line 422]

fields storage

API Tags:
Access:  protected


[ Top ]
array   $_hiddenValues = array() [line 427]

auto generated hidden fields storage

API Tags:
Access:  protected


[ Top ]
array   $_htmlTpls = array
(
'select_option' => '<option {attributes}>{label}</option>',
'select' => '<select name="{name}" {attributes}>{options}</select>',
'textarea' => '<textarea name="{name}" {attributes}>{value}</textarea>',
'input' => '<input type="{type}" name="{name}" {attributes}>',
'fieldset' => '<fieldset {attributes}>{label}{data} {start_tab}</fieldset>',
'form' => '<form {method} {action} {attributes}>{fields}</form>',
'spacer' => '<div style="clear:both;height:{spacerVal}"><!-- --></div>',
'label' => '<label {for} {attributes}>{label}</label>',
'legend' => '<legend {attributes}>{label}</legend>',
'span' => '<span {attributes}>{label}</span>',
'td' => '<td align="left" valign="top">',
'table' => '<table {attributes}>',
'field_container' => '<div {attributes}>{label}{field} {start_tab}</div>',
'main_container' => '<div style="width:{form_width}">{form}</div>'
)
[line 391]

html templates

API Tags:
Access:  protected


[ Top ]
array   $_storageKeys = array("events","attributes","validate","label","labelOptions","parentEl") [line 417]

possibile options in fields storage

API Tags:
Access:  protected


[ Top ]
array   $_validate = array() [line 432]

array of fields to validate

API Tags:
Access:  protected


[ Top ]
Methods
Constructor __construct  [line 19]

  PtcForms __construct( [array $options = null]  )

Set form method(POST,GET) and start the engine to keep sent values

Parameters:
array   $options:  array of options _defaultOptions

API Tags:
Access:  public

Information Tags:
Tutorial:  PtcForms.cls

[ Top ]
addField  [line 47]

  void addField( string $type, string $fieldName  )

Add input field to the object

Parameters:
string   $type:  the field type, view class manual for possible values
string   $fieldName:  name for the input field

API Tags:
Access:  public

Information Tags:
Tutorial:  PtcForms.cls

[ Top ]
addFieldAttributes  [line 109]

  void addFieldAttributes( string $fieldName, array|string $options  )

Add attributes to input field

Parameters:
string   $fieldName:  the name of the input field
array|string   $options:  attributes to add("class","id","style")

API Tags:
Access:  public


[ Top ]
addFieldEvent  [line 64]

  void addFieldEvent( $fieldName, $options  )

Alias of addFieldEvents()

Parameters:
   $fieldName: 
   $options: 

API Tags:
Access:  public


[ Top ]
addFieldEvents  [line 91]

  void addFieldEvents( string $fieldName, array $options  )

Add events to input field

Parameters:
string   $fieldName:  the name of the input field
array   $options:  events to add to the input field

API Tags:
Access:  public


[ Top ]
addFieldLabel  [line 76]

  void addFieldLabel( string $fieldName, string $label  )

Add a label text for the input field

Parameters:
string   $fieldName:  the name of the field
string   $label:  the label text for the input field

API Tags:
Access:  public

Information Tags:
Tutorial:  PtcForms.cls

[ Top ]
addFieldValidator  [line 100]

  void addFieldValidator( string $fieldName, array|string $options  )

Add validator for input field

Parameters:
string   $fieldName:  the name of the input field
array|string   $options:  add validator("required","email")

API Tags:
Access:  public


[ Top ]
addFieldValue  [line 55]

  void addFieldValue( $fieldName, $options  )

Alias of addFieldValues()

Parameters:
   $fieldName: 
   $options: 

API Tags:
Access:  public


[ Top ]
addFieldValues  [line 127]

  void addFieldValues( string $fieldName, array|string $options  )

Add values to input fields

Parameters:
string   $fieldName:  the name of the input field
array|string   $options:  value/s to add

API Tags:
Access:  public


[ Top ]
addLabelOptions  [line 82]

  void addLabelOptions( string $fieldName, array $options  )

Add attributes to the label

Parameters:
string   $fieldName:  the name of the field
array   $options:  attributes to add to the label("id","class","style")

API Tags:
Access:  public


[ Top ]
addSpacer  [line 178]

  void addSpacer( )

Add spacer div


API Tags:
Access:  public


[ Top ]
addValuesParams  [line 166]

  void addValuesParams( string $fieldName, $type, array $options  )

Add paramaters to field values group

Parameters:
string   $fieldName:  the name of the input field
array   $options:  value/s to add
   $type: 

API Tags:
Access:  public


[ Top ]
customElAttributes  [line 361]

  void customElAttributes( $attributes, array $templates  )

Manipulate/Add html elements attributes

Parameters:
array   $templates:  array of html templates
   $attributes: 

API Tags:
See:  PtcForms::$_elAttributes
Access:  public


[ Top ]
customTpl  [line 346]

  void customTpl( $templates  )

Alias of customTpls()

Parameters:
   $templates: 

API Tags:
Access:  public


[ Top ]
customTpls  [line 352]

  void customTpls( array $templates  )

Manipulate html templates

Parameters:
array   $templates:  array of html templates

API Tags:
See:  PtcForms::$_htmlTpls
Access:  public


[ Top ]
fieldParentEl  [line 118]

  void fieldParentEl( string $fieldName, array|string $options  )

Add attributes to div container for input field

Parameters:
string   $fieldName:  the name of the input field
array|string   $options:  attributes to add, view manual for possible values

API Tags:
Access:  public


[ Top ]
removeField  [line 69]

  void removeField( string $fieldName  )

Remove field(under development)

Parameters:
string   $fieldName:  the name of the field

API Tags:
Access:  public


[ Top ]
renderField  [line 216]

  void renderField( string $fieldName  )

Render field

Parameters:
string   $fieldName:  the name of the input field

API Tags:
Deprecated:  deprecated since version 8.0.b
Access:  public


[ Top ]
renderForm  [line 184]

  void renderForm( [array $attributes = array()], [array $events = array()]  )

Render form

Parameters:
array   $attributes:  add form attributes
array   $events:  add form events

API Tags:
Access:  public


[ Top ]
validateEmail  [line 308]

  void validateEmail( string $fieldName, array $array  )

Check if value is valid email

Parameters:
string   $fieldName:  the name of the input field
array   $array:  array of values to check

API Tags:
Access:  public


[ Top ]
validateEqualTo  [line 329]

  void validateEqualTo( string $fieldName, string $matchField, array $array  )

Check if value matches other field value

Parameters:
string   $fieldName:  the name of the input field
string   $matchField:  the name of the input field to match
array   $array:  array of values to check

API Tags:
Access:  public


[ Top ]
validateForm  [line 222]

  returns validateForm( )

Validate form fields defined with the addFieldValidator() method


API Tags:
Return:  fields to validate, an array with isValid(bool) and errors(array) as array keys
Access:  public

Information Tags:
Tutorial:  PtcForms.cls

[ Top ]
validateNumber  [line 319]

  void validateNumber( string $fieldName, array $array  )

Check if value is numeric

Parameters:
string   $fieldName:  the name of the input field
array   $array:  array of values to check

API Tags:
Access:  public


[ Top ]
validatePattern  [line 339]

  void validatePattern( string $fieldName, string $pattern, array $array  )

Check if given regex pattern is matched

Parameters:
string   $fieldName:  the name of the input field
string   $pattern:  the pattern to match(regex)
array   $array:  array of values to check

API Tags:
Access:  public


[ Top ]
validateRequired  [line 302]

  void validateRequired( string $fieldName, array $array  )

Check if value is empty

Parameters:
string   $fieldName:  the name of the input field
array   $array:  array of values to check

API Tags:
Access:  public


[ Top ]
validator  [line 60]

  void validator( )

Alias of validateForm()


API Tags:
Deprecated:  deprecated since version 5.0
Access:  public


[ Top ]
_addClassValidator  [line 813]

  void _addClassValidator( string $fieldName, array|string $options  )

Add validator classes to field for js validation

Parameters:
string   $fieldName:  the name of the field
array|string   $options:  the options to pass("required","email")

API Tags:
Access:  protected


[ Top ]
_addCompositeField  [line 464]

  void _addCompositeField( string $fieldName, array $values  )

Add composite for multiple layouts with html table

Parameters:
string   $fieldName:  the name of the input field
array   $values:  add previously configured fields to a table layout

API Tags:
Access:  protected


[ Top ]
_addDefaultValues  [line 483]

  void _addDefaultValues( string $array  )

Add empty default values when addField() is called

Parameters:
string   $array: 

API Tags:
See:  PtcForms::$_storageKeys
Access:  protected


[ Top ]
_addFieldParams  [line 714]

  void _addFieldParams( string $fieldName, array $type, array|string $options  )

Add parameters to field

Parameters:
string   $fieldName:  the name of the field
array   $type:  ("events","attributes","validate","label","labelOptions","parentEl","value")
array|string   $options:  the options to pass,view manual for details

API Tags:
Access:  protected


[ Top ]
_addInputStyle  [line 834]

  void _addInputStyle( string $fieldName, string $fieldStyle  )

Add default style to field to align properly

Parameters:
string   $fieldName:  the name of the field
string   $fieldStyle:  the style property

API Tags:
Access:  protected


[ Top ]
_addLabelStyle  [line 860]

  void _addLabelStyle( string $fieldName, string $labelContainer, string $style  )

Add default style to label to align properly

Parameters:
string   $fieldName:  the name of the field
string   $labelContainer:  the html template for label element
string   $style:  the style property

API Tags:
Access:  protected


[ Top ]
_addTableStyle  [line 877]

  void _addTableStyle( string $fieldName, string $tableStyle  )

Add default style to table to align properly

Parameters:
string   $fieldName:  the name of the field
string   $tableStyle:  the style property

API Tags:
Access:  protected


[ Top ]
_addValidator  [line 791]

  void _addValidator( string $fieldName, array|string $options  )

Add validator to input field

Parameters:
string   $fieldName:  the name of the field
array|string   $options:  the options to pass("required","email")

API Tags:
Access:  protected


[ Top ]
_buildAttributes  [line 916]

  void _buildAttributes( string $fieldName, string $container, string $arrKey  )

Build attributes for html elements

Parameters:
string   $fieldName:  the name of the field
string   $container:  the html template for container
string   $arrKey:  (events,attributes,validate,label,labelOptions,parentEl)

API Tags:
Access:  protected


[ Top ]
_buildContainer  [line 445]

  void _buildContainer( string $fieldName, string $fieldHtml, [string $labelHtml = ''], [bool $switch = false]  )

Build container for field

Parameters:
string   $fieldName:  the name of the input field
string   $fieldHtml:  the html field element
string   $labelHtml:  the html label element
bool   $switch:  reverse html label position with input field(for radio/checkbox)

API Tags:
Access:  protected


[ Top ]
_buildElAttributes  [line 904]

  void _buildElAttributes( string $container  )

Replace $_elAttributes with template {attributes}

Parameters:
string   $container:  the container html element

API Tags:
Access:  protected


[ Top ]
_buildField  [line 518]

  void _buildField( string $fieldName  )

Build fields

Parameters:
string   $fieldName:  the name of the input field

API Tags:
Access:  protected


[ Top ]
_buildHtml  [line 961]

  void _buildHtml( string $fieldName  )

Build container for field

Parameters:
string   $fieldName:  the name of the field

API Tags:
Access:  protected


[ Top ]
_buildLabel  [line 1052]

  void _buildLabel( string $case, string $alignLabel, string $labelWidth, string $labelHtml  )

Build label for field

Parameters:
string   $case:  (1,2,3)
string   $alignLabel:  ("left","top","right","none")
string   $labelWidth:  the width of the label as a percentage
string   $labelHtml:  the html template

API Tags:
Access:  protected


[ Top ]
_buildList  [line 939]

  void _buildList( string $fieldName  )

Build html select options

Parameters:
string   $fieldName:  the name of the select field

API Tags:
Access:  protected


[ Top ]
_buildTableData  [line 642]

  void _buildTableData( string $cols, string $type, string $fieldName, array $data, string $container  )

Build dynamic table for multiple layouts

Parameters:
string   $cols:  number of columns
string   $type:  the table type(1,2)
string   $fieldName:  the name of the field
array   $data:  the values for the table
string   $container:  the html table template

API Tags:
Access:  protected


[ Top ]
_checkErrors  [line 1145]

  void _checkErrors( $fieldName, $type, [ $function = null], [ $errType = null]  )

Check for errors while building or rendering the form

Parameters:
   $fieldName: 
   $type: 
   $function: 
   $errType: 

API Tags:
Access:  protected


[ Top ]
_editMethod  [line 1209]

  void _editMethod( $array  )

Change values in form method(POST,GET)

Parameters:
   $array: 

API Tags:
Access:  protected


[ Top ]
_rebuildValues  [line 997]

  void _rebuildValues( string $fieldName  )

Rebuild values for fields if POST or GET

Parameters:
string   $fieldName:  the name of the field

API Tags:
Access:  protected


[ Top ]
_switchLabelEl  [line 496]

  void _switchLabelEl( string $fieldName, string $labelText  )

Switch between span and label elements according to field type

Parameters:
string   $fieldName:  the name of the input field
string   $labelText:  the text for the label

API Tags:
Access:  protected


[ Top ]
_useMethod  [line 1198]

  void _useMethod( )

Retrieve form method(POST,GET)


API Tags:
Access:  protected


[ Top ]

Documentation generated on Sun, 27 Jan 2013 18:45:06 +0100 by phpDocumentor 1.4.3