Ferreteria/v2/usage/forms: Difference between revisions

From Woozle Writes Code
< Ferreteria‎ | v2‎ | usage
Jump to navigation Jump to search
(significant functions; version 2 imminent)
m (23 revisions imported: moving this project here)
 
(14 intermediate revisions by one other user not shown)
Line 1: Line 1:
==About==
==About==
''This page may be slightly out of date, e.g. class names may have changed.''
'''Forms''' in Ferreteria consist of several sets of classes that work together:
'''Forms''' in Ferreteria consist of several sets of classes that work together:
* '''control''' classes render editable (and eventually non-editable) data fields
* '''control''' classes render editable (and eventually non-editable) data fields
* '''field''' classes handle translating values between internal storage and on-disk storage (database)
* '''field''' classes handle translating values between internal storage and on-disk storage (database)
 
==Status==
Forms are in the process of being rewritten (version 2). The rest of this page applies to version 1.
* This is version 0.2 (originally designated version 2, but renumbered in 2020) of the Forms classes.
==Rules==
* It was rewritten from scratch in 2015, superseding [[Ferreteria/v0.1]].
* Every '''control''' (clsCtrl) belongs to a '''control row''' (clsCtrls).
* It is superseded by [[Ferreteria/v0.3]].
* '''Control row'''s can be indexed in order to allow for multi-row editing.
==Subpages==
* '''clsCtrls''' should eventually be renamed '''clsCtrlRow'''.
* [[/creating]]
* I haven't decided if there needs to be a clsForm class for containing multiple control rows.
* [[/displaying]]
** Indexing is optional if you're only editing one row at a time.
==Pages==
* {{l/ferreteria/|changes/1}}: change to Save() parameters
{| width=100%
{| width=100%
| valign=top bgcolor=#efe |
| valign=top bgcolor=#efe |
==Files==
==Files==
* {{ferreteria/code|util/forms.php}}
* {{ferreteria/code|forms/ctrl.php}}
** '''clsFields'''
** '''fcFormControl''' (abstract)
** '''clsField'''
*** '''fcFormControl_HTML''' &larr; fcFormControl
*** '''clsFieldTime'''
**** '''fcFormControl_HTML_TextArea''' &larr; fcFormControl_HTML
*** '''clsFieldNum'''
**** '''fcFormControl_HTML_Hidden''' &larr; fcFormControl_HTML
*** '''clsFieldBool'''
**** '''fcFormControl_HTML_DropDown''' &larr; fcFormControl_HTML
**** '''clsFieldBool_Int'''
**** '''fcFormControl_HTML_CheckBox''' &larr; fcFormControl_HTML
** '''clsCtrls''' (abstract)
* {{ferreteria/code|forms/field.php}}
** '''clsCtrl''' (abstract)
** '''fcFormField'''
*** '''clsCtrlHTML'''
*** '''fcFormField_Num''' &larr; fcFormField
**** '''clsCtrlHTML_CheckBox'''
*** '''fcFormField_Time''' &larr; fcFormField
**** '''clsCtrlHTML_DropDown'''
* {{ferreteria/code|forms/form.php}}
**** '''clsCtrlHTML_Hidden'''
** '''fcForm''' (abstract)
**** '''clsCtrlHTML_Fixed'''
*** '''fcForm_keyed''' &larr; fcForm
**** '''clsCtrlHTML_ReadOnly'''
* {{ferreteria/code|forms/form-data.php}}
**** '''clsCtrlHTML_Rating'''
** '''fcForm_DB''' &larr; fcForm_keyed
* {{ferreteria/code|form-data.php}}
* {{ferreteria/code|db/v1/menu-data.php}}
** {{faint|'''clsCtrls'''}}
** '''clsDataRecord_admin''' &larr; clsDataSet
*** '''clsForm_recs'''
**** '''clsForm_recs_indexed'''
| valign=top bgcolor=#eef |
| valign=top bgcolor=#eef |
==Classes==
==Classes==
The way this is organized is a little messed up; the descendants of clsCtrls handle database interaction -- but shouldn't it be the descendants of clsFields? It works reasonably well as is, but some rethinking might be a good idea, once everything is all mapped out.
* '''fcForm''' (abstract)
===collections===
** '''fcForm_keyed''' &larr; fcForm
* '''clsCtrls''' (abstract): a collection of '''clsCtrl''' form controls -- often referred to in code as a "form object"
*** '''fcForm_DB''' &larr; fcForm_keyed
** '''clsForm_recs''': form object that knows how to interact with a database table
* '''fcFormField'''
*** '''clsForm_recs_indexed''': form object that knows how to interact with a ''keyed'' database table (allowing for additional functionality)
** '''fcFormField_Num''' &larr; fcFormField
* '''clsFields''': a collection of '''clsField''' objects
** '''fcFormField_Time''' &larr; fcFormField
===unitary objects===
* '''fcFormControl''' (abstract)
* '''clsField''': a generic (unspecialized) field, suitable for plain text
** '''fcFormControl_HTML''' &larr; fcFormControl
** '''clsFieldTime''': field for storing date/time
*** '''fcFormControl_HTML_TextArea''' &larr; fcFormControl_HTML
** '''clsFieldNum''': field for storing numeric (int or float) data
*** '''fcFormControl_HTML_Hidden''' &larr; fcFormControl_HTML
** '''clsFieldBool''': field for storing a BIT-type boolean field (which, oddly, is returned as a single character instead of numeric)
*** '''fcFormControl_HTML_DropDown''' &larr; fcFormControl_HTML
*** should be renamed clsFieldBool_bit, or maybe this class should be abstract and clsFieldBool_bit should descend from it
*** '''fcFormControl_HTML_CheckBox''' &larr; fcFormControl_HTML
*** '''clsFieldBool_Int''': field for storing a boolean value stored as an integer
* '''clsDataRecord_admin'''
* '''clsCtrl''' (abstract): a generic UI control
** '''clsCtrlHTML''': a control for an HTML form, suitable for single-line text entry
*** '''clsCtrlHTML_TextArea''': HTML multiline text entry control
*** '''clsCtrlHTML_CheckBox''': HTML checkbox control
*** '''clsCtrlHTML_DropDown''': HTML single-choice drop-down control
*** '''clsCtrlHTML_Hidden''': HTML invisible control, for returning calculated data
*** '''clsCtrlHTML_Fixed''': HTML control for displaying pre-set data; useful for creating new records
*** '''clsCtrlHTML_ReadOnly''': HTML control for non-editable data
*** '''clsCtrlHTML_Rating''': HTML control for entering a rating (integer with fixed range and intervals)
|}
|}
==Significant Functions==
==Significant Functions==
* clsCtrls (abstract)
* '''fcForm'''
** function '''Ctrl({{arg|name}})''' &rarr; clsCtrl
** ControlArray({{arg|array of control objects (optional)}}) - set/get all control objects
** function '''FieldsObject()''' &rarr; clsForm_recs_indexed
** ControlObject({{arg|name}},{{arg|control object (optional)}}) - set/get control object for given name
* clsCtrl (abstract)
** AddField({{arg|field object}}, {{arg|control object}})
** function '''Field()''' &rarr; clsField
** abstract LoadRecord()
** function '''RowObject()''' &rarr; clsCtrls
** abstract SaveRecord()
* clsFields
** RecordValue({{arg|name}},{{arg|value (optional)}}) - set/get field value
** function '''DefaultValues()''' &rarr; array of mixed
** RecordValues({{arg|array of values (optional)}}) - set/get all field values
* clsField
** NewValues({{arg|array of values (optional)}}) - set/get values for new records
** function '''ValStore()''' &rarr; mixed
** ClearValues()
** function '''ValShow()''' &rarr; string
** RenderControls({{arg|edit?}})
 
* '''fcForm_keyed'''
* clsCtrls &rarr; clsCtrl array
** Get_KeyString_loaded()
* clsCtrl &rarr;
** Set_KeyString_loaded({{arg|key string}})
** Get_KeyString_toSave()
** Set_KeyString_toSave({{arg|key string}})
** HasKey()
* '''fcForm_DB'''
** RecordsObject({{arg|recordset object (optional)}}) - set/get recordset object
** RecordValues_SQL() - get array of SQL-ready record values
** LoadRecord()
** SaveRecord()
* '''fcFormField'''
** FormObject({{arg|form object (optional)}}) - set/get form object
** NameString({{arg|name string (optional)}}) - set/get field's name
** ValueNative({{arg|value string (optional)}}) - set/get field's internal value
** ValueDisplay({{arg|value string (optional)}}) - set/get field's display value
** ValueSQL({{arg|value string (optional)}}) - set/get field's SQL value
** static Convert_DisplayToNative({{arg|value string}})
** static Convert_NativeToDisplay({{arg|value string}})
** static Convert_SQLToNative({{arg|value string}})
** static Convert_NativeToSQL({{arg|value string}})
* '''fcFormControl'''
** FormObject({{arg|form object (optional)}}) - set/get form object
** FieldObject({{arg|field object (optional)}}) - set/get field object
** abstract Render({{arg|edit?}})
* '''clsDataRecord_admin'''
** callbacks:
*** AdminRows(array $arFields,array $arOptions=NULL)
*** AdminRows_none(array $arOptions=NULL) - called if there are no rows
*** AdminRows_start(array $arOptions=NULL) - called before first row; by default, opens an HTML table
*** AdminRows_finish(array $arOptions=NULL) - called after last row; by default, closes the HTML table
*** AdminRows_after(array $arOptions=NULL) - called just before AdminRows() exits, regardless of whether there were rows
*** AdminRows_head(array $arFields,array $arOptions=NULL) - called after AdminRows_start(); by default, displays row headers
*** AdminRows_rows(array $arFields,array $arOptions=NULL) - called before AdminRows_finish(); useful for displaying totals
*** AdminField($sField,array $arOptions=NULL) - called for each field to display in AdminRows()

Latest revision as of 16:46, 22 May 2022

About

This page may be slightly out of date, e.g. class names may have changed.

Forms in Ferreteria consist of several sets of classes that work together:

  • control classes render editable (and eventually non-editable) data fields
  • field classes handle translating values between internal storage and on-disk storage (database)

Status

  • This is version 0.2 (originally designated version 2, but renumbered in 2020) of the Forms classes.
  • It was rewritten from scratch in 2015, superseding Ferreteria/v0.1.
  • It is superseded by Ferreteria/v0.3.

Subpages

Files

Classes

  • fcForm (abstract)
    • fcForm_keyed ← fcForm
      • fcForm_DB ← fcForm_keyed
  • fcFormField
    • fcFormField_Num ← fcFormField
    • fcFormField_Time ← fcFormField
  • fcFormControl (abstract)
    • fcFormControl_HTML ← fcFormControl
      • fcFormControl_HTML_TextArea ← fcFormControl_HTML
      • fcFormControl_HTML_Hidden ← fcFormControl_HTML
      • fcFormControl_HTML_DropDown ← fcFormControl_HTML
      • fcFormControl_HTML_CheckBox ← fcFormControl_HTML
  • clsDataRecord_admin

Significant Functions

  • fcForm
    • ControlArray(<array of control objects (optional)>) - set/get all control objects
    • ControlObject(<name>,<control object (optional)>) - set/get control object for given name
    • AddField(<field object>, <control object>)
    • abstract LoadRecord()
    • abstract SaveRecord()
    • RecordValue(<name>,<value (optional)>) - set/get field value
    • RecordValues(<array of values (optional)>) - set/get all field values
    • NewValues(<array of values (optional)>) - set/get values for new records
    • ClearValues()
    • RenderControls(<edit?>)
  • fcForm_keyed
    • Get_KeyString_loaded()
    • Set_KeyString_loaded(<key string>)
    • Get_KeyString_toSave()
    • Set_KeyString_toSave(<key string>)
    • HasKey()
  • fcForm_DB
    • RecordsObject(<recordset object (optional)>) - set/get recordset object
    • RecordValues_SQL() - get array of SQL-ready record values
    • LoadRecord()
    • SaveRecord()
  • fcFormField
    • FormObject(<form object (optional)>) - set/get form object
    • NameString(<name string (optional)>) - set/get field's name
    • ValueNative(<value string (optional)>) - set/get field's internal value
    • ValueDisplay(<value string (optional)>) - set/get field's display value
    • ValueSQL(<value string (optional)>) - set/get field's SQL value
    • static Convert_DisplayToNative(<value string>)
    • static Convert_NativeToDisplay(<value string>)
    • static Convert_SQLToNative(<value string>)
    • static Convert_NativeToSQL(<value string>)
  • fcFormControl
    • FormObject(<form object (optional)>) - set/get form object
    • FieldObject(<field object (optional)>) - set/get field object
    • abstract Render(<edit?>)
  • clsDataRecord_admin
    • callbacks:
      • AdminRows(array $arFields,array $arOptions=NULL)
      • AdminRows_none(array $arOptions=NULL) - called if there are no rows
      • AdminRows_start(array $arOptions=NULL) - called before first row; by default, opens an HTML table
      • AdminRows_finish(array $arOptions=NULL) - called after last row; by default, closes the HTML table
      • AdminRows_after(array $arOptions=NULL) - called just before AdminRows() exits, regardless of whether there were rows
      • AdminRows_head(array $arFields,array $arOptions=NULL) - called after AdminRows_start(); by default, displays row headers
      • AdminRows_rows(array $arFields,array $arOptions=NULL) - called before AdminRows_finish(); useful for displaying totals
      • AdminField($sField,array $arOptions=NULL) - called for each field to display in AdminRows()