Framework  3.9
AutoForm Class Reference

AutoForm automatically creates a form based on an underlying DataItem. More...

+ Inheritance diagram for AutoForm:

Public Member Functions

 AutoForm ($target, $method="POST", $action="", $id="")
 Creates a new AutoForm, based on the supplied target DataItem. More...
 
 getData ()
 Returns the target data item for the form. More...
 
 setDataSet ($params)
 
 setLayout ($layout)
 Override the default layout manager. More...
 
 setFieldOrder ()
 Override the display order for ungrouped field. More...
 
 createRenderer ($field)
 This factory method creates a FieldRender based on the type of the specified field. More...
 
 addDefaultValidators ()
 Creates default validators for fields in the form. More...
 
 getValidationEngine ()
 Retrieve the validation engine for this AutoForm. More...
 
 makeSubordinate ()
 Set this AutoForm to be a subordinate form within a CompositeAutoForm. More...
 
 configureValidators ()
 
 writeScript ()
 This method writes any Javascript code that will be required for the generated form to operate, including code for Rich Text Editors, Date Pickers and field validation. More...
 
 getRenderer ($field)
 Retrieves the FieldRenderer object for the specified field. More...
 
 override ($field, $label="", $renderer=null)
 Overrides the defaults for the specifed form field, providing a new label and/or FieldRenderer. More...
 
 overrideType ($field, $type, $label="")
 Override the default type for the specified form field, providing a FieldRenderer based on the supplied type (and optionally also override the field label) More...
 
 add ($renderer, $field="", $label="")
 Adds an additional (pseudo) field to the form. More...
 
 hide ()
 Call this method to hide one or more fields in the form's user interface. More...
 
 hideExcept ()
 Call this method to hide all the fields in the form's user interface EXCEPT the fields specified. More...
 
 isHidden ($field)
 Check whether the specified field is hidden in the form. More...
 
 annotate ($field, $text)
 Adds an annotation (such as brief explanatory text) to the specified field. More...
 
 alias ()
 Use this method to override the display name for fields in the form. More...
 
 related ($class, $constraint="", $format=null, $field=null, $label=null, $allowAdd=false, $allowNone=true)
 Utility function to add a RelatedItemSelectFieldRender. More...
 
 crossReference ($xrefClass, $options, $format, $field, $label=null, $xrefField=null)
 Utility function to add a CrossReferenceSelectFieldRenderer. More...
 
 dropdown ($field, $label="", $options=null, $onchange=null, $grouped=false)
 Utility function to add a SelectFieldRenderer. More...
 
 groupedDropdown ($field, $label, $options, $onchange=null)
 Utility function to add a SelectFieldRenderer with grouped options. More...
 
 radio ($field, $label, $options, $onchange=null)
 Utility function to add a RadioButtonFieldRenderer. More...
 
 checklist ($field, $label, $options, $grouped=false)
 Utility function to add a CheckListFieldRenderer. More...
 
 toggle ($field, $label="", $ragged=false)
 Utility function to create a ToggleFieldRenderer. More...
 
 group ($name)
 Define a field grouping. More...
 
 addToGroup ($name)
 Add more fields to the specified group. More...
 
 groupDescription ($name, $description, $position='start')
 Add a description block to a group. More...
 
 getGroupDescription ($name, $position='start')
 Retrieves the group description for the specified group. More...
 
 makeGroupCollapsible ($name, $toggleControl)
 Allows a group to be shown or hidden based on the value of another control. More...
 
 setGroupCSSClass ($name, $cssClass)
 Sets a specific CSS class on the specified CSS group. More...
 
 getGroupCSSClass ($name)
 Gets the CSS class for the specified group, if one has been set. More...
 
 removeGroup ($name)
 Remove the specified field grouping from the form. More...
 
 hideLabel ()
 Use this method to hide the labels for the specified fields in the form. More...
 
 readonly ()
 Call this method to make one or more fields read-only in the form's user interface. More...
 
 isReadOnly ($field)
 Determine whether the specified field is being displayed read-only. More...
 
 required ()
 Call this method to mark one or more fields as being required fields. More...
 
 hasAdditional ($field)
 Check if this field exists as an additional field. More...
 
 isRequired ($field)
 Determine whether the specified field is a required field for the form. More...
 
 requiredIfChecked ($field, $checkbox, $fieldTitle="", $checkboxTitle="", $message="")
 Make a field required if a given checkbox is checked. More...
 
 requiredSubSelect ($field, $fieldTitle, $subFieldTitle="", $message="")
 Make a subselect field required. More...
 
 regexp ($field, $expr, $message)
 Validate the user input for the specified field against a regular expression, outputting the supplied message if the entered value does not match. More...
 
 dateRange ($field, $min="", $max="", $message=null)
 
 unique ()
 Adds a uniqueness validator to the specified field(s). More...
 
 uniqueWithConstraint ($field, $message, $constraint="")
 
 range ($field, $min, $max, $message=null)
 Adds a range validator to the specified field. More...
 
 match ($field, $title, $match, $matchTitle, $caseSensitive=true)
 Specifies that two field values must match (as in a password/confirmation pair, for instance). More...
 
 password ($field, $title)
 Adds a password validator to the specified field. More...
 
 disableAutoComplete ()
 Disable autocomplete for the selected fields. More...
 
 button ($text, $url, $confirm=null, $isScript=false, $cssClass=null)
 Adds a custom button to the form. More...
 
 ajaxSubmit ($success, $failure=null)
 Put the form into AJAX submission mode. More...
 
 partialSaveButton ($containerID, $label="Save")
 Activate partial saves for this form. More...
 
 matchesSubmitted ()
 Determine if this form is the one that was submitted. More...
 
 drawForm ()
 Renders the form to HTML. More...
 
 drawSubmitButtons ($obj, $pk, $submitLabel)
 
 renderAllFields ($obj)
 
 renderFields ($obj)
 
 renderOneField ($field, $renderScript=false)
 
 renderAdditionalFields ($obj)
 
 drawButtons ()
 Draws any additional buttons specified in the calling script. More...
 
 drawReadOnly ()
 Draws the form in read-only mode. More...
 
 prettifyFieldName ($field)
 Generates a human-readable label from the given field name. More...
 
 load ($id)
 Loads the underlying DataItem from the database, using the specified primary key value. More...
 
 save ()
 Saves the posted values to the database. More...
 
 handlePartialSave ($success)
 
 preProcessFields ($pk, $filter)
 
 postProcessFields ($pk, $filter)
 
 remove (&$obj)
 
 validate ()
 Validate the posted values for the form. More...
 
 patchUpReferences ()
 

Static Public Member Functions

static registerFieldRendererClass ($type, $rendererClass)
 Registers a custom type-to-renderer mapping. More...
 

Public Attributes

 $formCSS = ""
 CSS Class to use for the table containing the form. More...
 
 $labelCSS = ""
 CSS Class to use for label cells. More...
 
 $valueCSS = ""
 CSS Class to use for field/value cells. More...
 
 $buttonCSS = ""
 CSS Class to use for buttons. More...
 
 $buttonLineCSS = "submit"
 CSS Class to use for the button line (container for form buttons) More...
 
 $inputCSS = ""
 CSS Class to use for input fields. More...
 
 $checkboxCSS = ""
 CSS Class to use for checkbox fields. More...
 
 $style = ""
 
 $componentPath ="/fakoli"
 
 $buttonAlignment = "left"
 Default Form button alignment. More...
 
 $passwordEncryptor = ""
 Password Encryption method name. More...
 
 $hideButtons = false
 Set to true to hide form submission button line(s) More...
 
 $capitalizationMode = "word"
 Capitalization to be used for labels. Can be 'lower', 'upper', 'first' or 'word'. More...
 
 $submitLabel = ""
 Text to display on the form's submit button. If not specified defaut text will be generated based on the target DataItem. More...
 
 $allowDelete = false
 If true, the form will display a delete button if editing an existing item. More...
 
 $deleteLabel = ""
 Text to display on the form's delete button. If not specified defaut text will be generated based on the target DataItem. More...
 
 $deleteMessage = ""
 Confirmation message to display when the form's delete button is pressed. If not specified defaut text will be generated based on the target DataItem. More...
 
 $method = "POST"
 HTTP method that will be used to submit the form. More...
 
 $action = ""
 Action URL for submitting the form. Generally this can be left blank to submit back to the same page. More...
 
 $renderers = array()
 The field renderers collection. More...
 
 $overrides = array()
 The field overrides collection. More...
 
 $hidden = array()
 The hidden fields collection. More...
 
 $additional = array()
 The additional (pseudo) fields collection. More...
 
 $additional_at_top = false
 whether additional fields are rendered above the datamodel's field list; if false, then rendered below More...
 
 $readonly = array()
 The read-only fields collection. More...
 
 $annotations = array()
 The field annotations collection. More...
 
 $buttons = array()
 The custom buttons collection. More...
 
 $fieldOrder = array()
 The order in which to display ungrouped fields. More...
 
 $validator
 The ValidationEngine for this form. More...
 
 $useLinkSubmit = false
 Flag to indicate whether the submit button for the form should be rendered as a link (not common). More...
 
 $HTMLEditorHideStyleBar = false
 Flag to indicate that Rich Text Editors should be displayed with or without the style editing toolbar. More...
 
 $HTMLEditorDefaultWidth = "540px"
 Default width for Rich Text Editor controls. More...
 
 $HTMLEditorDefaultHeight = "200px"
 Default height for Rich Text Editor controls. More...
 
 $passwordEnterLabel = "Enter"
 Text for Password Enter label. More...
 
 $passwordConfirmLabel = "Confirm"
 Text for Password Confirm label. More...
 
 $onDrawStart = null
 Callback event handler that is fired just prior to drawing the form. More...
 
 $onDrawComplete = null
 Callback event handler that is fired just after the form been drawn. More...
 
 $onInsertPreProcess = null
 Callback event handler that is fired after fields have been preprocessed, but before the data has been saved to the database as a new record. More...
 
 $onSavePreProcess = null
 Callback event handler that is fired after fields have been preprocessed, but before the data has been saved to the database. More...
 
 $onSaveComplete = null
 Callback event handler that is fired after the AutoForm has finished saving data to the database. More...
 
 $confirmPrompt = null
 Specify a confirmation message. This will be shown to the user to have them confirm the form submission after the submit button is pressed. More...
 
 $onDelete = ""
 delete method name More...
 
 $customSaveHandler = null
 Use this field to override the default save behavior of your form. More...
 
 $markRequiredFields = false
 Set to true to add an asterisk after required field labels. More...
 
 $onFormatLabel = null
 Label Processing hook. More...
 
 $buttons_at_top = false
 
 $ajaxSubmitHandler = false
 JavaScript Callback for AJAX Submit mode - called on success. More...
 
 $ajaxFailureHandler = false
 JavaScript Callback for AJAX Submit mode - called on failure. More...
 
 $onSubmitHandler = null
 Javascript Callback for user-defined onsubmit hook. More...
 
 $required = array()
 List of required fields. More...
 
 $requiredFieldsText = "* indicates required field"
 Text prompt to display when a form contains required fields. More...
 
 $interstitialMessage = null
 Specifies the message to display in an interstitial while the form is being submitted. More...
 
 $interstitialSpinner = '/fakoli/images/loader.gif'
 Set this property to override the default interstitial spinner animation. More...
 
 $fields
 Local field cache. More...
 
 $groups = array()
 List of field groups. More...
 
 $collapsibleGroups = array()
 List of collapsible groups and their default states. More...
 
 $groupDescriptions = array()
 List of group descriptions. More...
 
 $groupDescriptionCSS = "group_description"
 CSS class for group description blocks. More...
 
 $groupCSSClasses = array()
 Additional classes for specific groups. More...
 
 $readOnlyForm
 Specifies whether the entire form is read-only. More...
 
 $subordinate
 Specifies whether this form is a subordinate member of a composite form. More...
 
 $hideEmptyFields = false
 Specifies whether to hide empty fields when displaying a read-only form. More...
 
 $showAnnotations = true
 Set to false to hide field annotations. More...
 
 $layout
 Layout handler object. More...
 
 $default_layout = "table"
 
 $allowPartialSave = false
 Whether to allow partial (i.e. in-progress) saves via AJAX. More...
 
 $partialSaveContainerID
 DOM ID for the element that will contain the partial save button. More...
 
 $partialSaveLabel = "Save"
 Label text for the partial save button. More...
 

Static Public Attributes

static $fieldRendererMap
 Provides the mapping from Type identifier to FieldRenderer. More...
 

Detailed Description

AutoForm automatically creates a form based on an underlying DataItem.

Definition at line 45 of file auto_form.inc.

Member Function Documentation

◆ add()

AutoForm::add (   $renderer,
  $field = "",
  $label = "" 
)

Adds an additional (pseudo) field to the form.

This can be used to render additional fields in the user interface that are not directly tied to single fields in the underlying DataItem (for instance, to provide a checkbox list for many-to-one relationships, etc)

Parameters
mixed$renderereither a mapped type (String, Number, etc), or a FieldRenderer-derived object to use for the additional field.
string$fieldthe name of the additional field
string$label(optional) label for the additional field

Definition at line 594 of file auto_form.inc.

595  {
596  if (is_string($renderer))
597  {
598  if (array_key_exists($renderer, AutoForm::$fieldRendererMap))
599  {
600  $renderer = new AutoForm::$fieldRendererMap[$renderer]($this, $field);
601  }
602  else
603  {
604  throw new FakoliException("Unknown Type - {$renderer}");
605  }
606  }
607 
608  array_push($this->additional, array('renderer' => $renderer, 'field' => $field));
609  if ($field && $label)
610  {
611  $this->alias($field, $label);
612  }
613  }
static $fieldRendererMap
Provides the mapping from Type identifier to FieldRenderer.
Definition: auto_form.inc:134
alias()
Use this method to override the display name for fields in the form.
Definition: auto_form.inc:684

◆ addDefaultValidators()

AutoForm::addDefaultValidators ( )

Creates default validators for fields in the form.

Currently this adds Date format validators to all date fields - other fields are not affected.

This method is called automatically before the form is rendered.

Reimplemented in SearchForm.

Definition at line 311 of file auto_form.inc.

312  {
313  $filter = $this->data->getFilter();
314 
315  foreach(array_keys($this->fields) as $field)
316  {
317  if ($filter && $filter->isExcluded($field)) continue;
318  if ($this->readonly[$field]) continue; // No need to validate readonly fields
319 
320  $renderer = $this->getRenderer($field);
321  if ($renderer)
322  {
323  // JDG 9/19/2010 - let each renderer supply its own validator
324  $required = (array_search($field, $this->required) === FALSE) ? false : true;
325  $renderer->addValidatorsToForm($field, $required);
326  }
327  }
328 
329  foreach($this->additional as $r)
330  {
331  // JDG 5/2012 - check if additional field is required
332  $required = (array_search($r['field'], $this->required) === FALSE) ? false : true;
333  $r['renderer']->addValidatorsToForm($r['field'], $required);
334  }
335  }
readonly()
Call this method to make one or more fields read-only in the form's user interface.
Definition: auto_form.inc:910
required()
Call this method to mark one or more fields as being required fields.
Definition: auto_form.inc:933
getRenderer($field)
Retrieves the FieldRenderer object for the specified field.
Definition: auto_form.inc:512
$required
List of required fields.
Definition: auto_form.inc:106

◆ addToGroup()

AutoForm::addToGroup (   $name)

Add more fields to the specified group.

Parameters
string$namethe name of the group

Definition at line 817 of file auto_form.inc.

818  {
819  if (!array_key_exists($name, $this->groups))
820  {
821  $this->groups[$name] = array();
822  }
823 
824  for($i = 1; $i < func_num_args(); ++$i)
825  {
826  $this->groups[$name][] = func_get_arg($i);
827  }
828  }

◆ ajaxSubmit()

AutoForm::ajaxSubmit (   $success,
  $failure = null 
)

Put the form into AJAX submission mode.

You must supply a Javascript function to call once the submission is complete.

Parameters
string$successthe Javascript callback function for success
string$failurethe Javascript callback function for failure

Definition at line 1157 of file auto_form.inc.

1158  {
1159  if ($failure == null)
1160  {
1161  $failure = "function() {document.id('{$form->id}_error').set('text','Failed to communicate with server'); }";
1162  }
1163 
1164  $this->ajaxSubmitHandler = $success;
1165  $this->ajaxFailureHandler = $failure;
1166  }

◆ alias()

AutoForm::alias ( )

Use this method to override the display name for fields in the form.

For instance, calling alias('x1', 'Useful Label') would display the text 'Useful Label' as the label for field 'x1' when rendering the form. You can alias more than one field with a single call to alias, simply by passing in more than one pairs of strings. For instance, you might call: alias('x1', 'Field 1', 'x2', 'Field 2', ...)

Definition at line 684 of file auto_form.inc.

685  {
686  for($i = 0; $i < func_num_args(); $i += 2)
687  {
688  $field = func_get_arg($i);
689  $label = func_get_arg($i + 1);
690  $this->override($field, $label);
691  }
692  }

◆ annotate()

AutoForm::annotate (   $field,
  $text 
)

Adds an annotation (such as brief explanatory text) to the specified field.

The annotation is displayed next to the field when the form is renderered.

Parameters
string$fieldthe name of the field to annotate
string$textthe annotation text

Definition at line 670 of file auto_form.inc.

671  {
672  $this->annotations[$field] = $text;
673  }

◆ AutoForm()

AutoForm::AutoForm (   $target,
  $method = "POST",
  $action = "",
  $id = "" 
)

Creates a new AutoForm, based on the supplied target DataItem.

Parameters
DataItem$targetthe DataItem object upon which the form will be based
string$methodthe HTTP method to be used for submitting the form (default is POST)
string$actionthe HTTP action URL to be used for submitting the form (default is to post back to the originating URL)
string$idDOM element ID to use for the form when rendering to HTML. Useful for pages with more than one form.
Returns
AutoForm

Definition at line 166 of file auto_form.inc.

167  {
168  global $auto_form_defaults;
169 
170  $this->subordinate = false;
171 
172  $this->validator = new ValidationEngine();
173 
174  foreach($auto_form_defaults as $field => $value)
175  {
176  $this->$field = $value;
177  }
178 
179  if (!$target)
180  {
181  throw new FakoliException("Form has no target object");
182  }
183 
184  $this->data =& $target;
185  $this->method = $method;
186  $this->action = $action;
187  $this->id = ($id != "") ? $id : get_class($this->data)."_form";
188 
189  $this->validator->id = $this->id;
190 
191  $this->fields = $this->data->getFields();
192 
193  $filter = $this->data->getFilter();
194 
195  // Add in a default renderer for each field
196  foreach($this->fields as $field => $type)
197  {
198  if ($filter && $filter->isExcluded($field)) continue;
199 
200  $this->renderers[$field] = $this->createRenderer($field);
201  }
202 
203  $aliases = $this->data->getFieldAliases();
204  // Read in default alias definitions from DataItem
205  if ($aliases)
206  {
207  foreach($aliases as $field => $alias)
208  {
209  $this->alias($field, $alias);
210  }
211  }
212 
213  $annotations = $this->data->getFieldAnnotations();
214  // Read in default annotations from DataItem
215  if ($annotations)
216  {
217  foreach($annotations as $field => $annotation)
218  {
219  $this->annotate($field, $annotation);
220  }
221  }
222 
223  $pks = $this->data->getPrimaryKeyList();
224  foreach($pks as $p)
225  {
226  $this->hide($p);
227  }
228 
229  $hiddenFields = $this->data->getHiddenFields();
230  foreach($hiddenFields as $h)
231  {
232  $this->hide($h);
233  }
234 
235  $this->layout = AutoFormLayout::create($this->default_layout, $this);
236  }
createRenderer($field)
This factory method creates a FieldRender based on the type of the specified field.
Definition: auto_form.inc:278
$action
Action URL for submitting the form. Generally this can be left blank to submit back to the same page.
Definition: auto_form.inc:68
annotate($field, $text)
Adds an annotation (such as brief explanatory text) to the specified field.
Definition: auto_form.inc:670
$method
HTTP method that will be used to submit the form.
Definition: auto_form.inc:67
hide()
Call this method to hide one or more fields in the form's user interface.
Definition: auto_form.inc:624
$annotations
The field annotations collection.
Definition: auto_form.inc:76
static create($type, $form)
The ValidationEngine takes an array of validator objects in its constructor, and is then able to gene...

◆ button()

AutoForm::button (   $text,
  $url,
  $confirm = null,
  $isScript = false,
  $cssClass = null 
)

Adds a custom button to the form.

Parameters
string$textthe button label text
string$urlthe URL to handle the button press
string$confirmoptional confirmation message
boolean$isScripttrue if the url is javascript code to execute, false if it is a URL to redirect to
string$cssClassoptional CSS class(es) to apply to the button

Definition at line 1146 of file auto_form.inc.

1147  {
1148  $this->buttons[] = array('text' => $text, 'url' => $url, 'confirm' => $confirm, 'isScript' => $isScript, 'cssClass' => $cssClass);
1149  }

◆ checklist()

AutoForm::checklist (   $field,
  $label,
  $options,
  $grouped = false 
)

Utility function to add a CheckListFieldRenderer.

Parameters
string$labelthe label for the field
array$optionsassociative array of grouped options
See also
CheckListFieldRenderer
Parameters
bool$groupedtrue if the options are grouped, false otherwise (default)

Definition at line 779 of file auto_form.inc.

780  {
781  return new CheckListFieldRenderer($this, $field, $label, $options, $grouped);
782  }
CheckListFieldRenderer: Renders the specified list of options as a list of checkboxes from which mult...

◆ configureValidators()

AutoForm::configureValidators ( )

Definition at line 353 of file auto_form.inc.

354  {
355  if ($this->validatorsConfigured) return;
356 
357  $this->addDefaultValidators();
358 
359  foreach($this->validator->validators as $v)
360  {
361  $v->title = (!$v->title) ? $this->prettifyFieldName($v->field) : $v->title;
362  $v->readOnly = $this->isReadOnly($v->field) || $this->isHidden($v->field);
363  }
364 
365  $this->validatorsConfigured = true;
366  }
isHidden($field)
Check whether the specified field is hidden in the form.
Definition: auto_form.inc:658
isReadOnly($field)
Determine whether the specified field is being displayed read-only.
Definition: auto_form.inc:923
addDefaultValidators()
Creates default validators for fields in the form.
Definition: auto_form.inc:311
prettifyFieldName($field)
Generates a human-readable label from the given field name.
Definition: auto_form.inc:1512

◆ createRenderer()

AutoForm::createRenderer (   $field)

This factory method creates a FieldRender based on the type of the specified field.

Parameters
string$fieldthe field for which the FieldRenderer is to be created
Returns
FieldRenderer a FieldRenderer object suitable for the specified field.

Definition at line 278 of file auto_form.inc.

279  {
280  if (!array_key_exists($field, $this->fields)) return null;
281 
282  $type = $this->fields[$field];
283 
284  if ($type == "Timestamp") return null; // No field renderer required for this type
285 
286  if (array_key_exists($type, AutoForm::$fieldRendererMap))
287  {
288  return new AutoForm::$fieldRendererMap[$type]($this, $field);
289  }
290 
291  throw new FakoliException("AutoForm::createRenderer(): Unknown type '$type'");
292  }

◆ crossReference()

AutoForm::crossReference (   $xrefClass,
  $options,
  $format,
  $field,
  $label = null,
  $xrefField = null 
)

Utility function to add a CrossReferenceSelectFieldRenderer.

Parameters
string$xrefClassthe name of the cross-reference DataItem class
array$optionsarray of possible target DataItems
string$formatthe format specifier to use when outputting the optio0ns
string$fieldfield name for use during form submission (should not be an actual field name)
string$labelthe label text to display
string$xrefFieldthe name of the field mapping the primary key of the target DataItems (only specify this if the field name is different from the primary key)
Returns
CrossReferenceSelectFieldRenderer

Definition at line 728 of file auto_form.inc.

729  {
730  if (!$label) $label = prettify($field);
731  return new CrossReferenceSelectFieldRenderer($this, $field, $label, $options, $format, $xrefClass, $xrefField);
732  }
prettify($name)
Takes a variable or field name and converts it into a human-readable version (assuming that the origi...
Definition: functions.inc:1413

◆ dateRange()

AutoForm::dateRange (   $field,
  $min = "",
  $max = "",
  $message = null 
)
Parameters
string$field
string,Date,orDateTime $min
string,Dateor DateTime $max
string$messageMin can be either a static date min that the field's value must be set to or the name of a field whose value will be compared to the given field.

E.g., start_date must be no earlier than today or start_date must be no earlier than end_date

Definition at line 1035 of file auto_form.inc.

1036  {
1037  if ($this->data->hasField($field))
1038  {
1039  $this->validator->add(new DateRangeValidator($field, $this->prettifyFieldName($field), $min, $max, $message));
1040  }
1041  }

◆ disableAutoComplete()

AutoForm::disableAutoComplete ( )

Disable autocomplete for the selected fields.

If no fields are specified, autocomplete is disabled for all the fields in the form.

Definition at line 1110 of file auto_form.inc.

1111  {
1112  $numArgs = func_num_args();
1113 
1114  if ($numArgs == 0)
1115  {
1116  foreach($this->data->getFields() as $field => $type)
1117  {
1118  if ($this->data->hasField($field))
1119  {
1120  $this->getRenderer($field)->autocomplete = false;
1121  }
1122  }
1123  }
1124  else
1125  {
1126  for($i = 0; $i < $numArgs; ++$i)
1127  {
1128  if ($this->data->hasField($field))
1129  {
1130  $this->getRenderer($field)->autocomplete = false;
1131  }
1132  }
1133  }
1134  }

◆ drawButtons()

AutoForm::drawButtons ( )

Draws any additional buttons specified in the calling script.

Definition at line 1459 of file auto_form.inc.

1460  {
1461  foreach($this->buttons as $button)
1462  {
1463  $url = ($button['isScript']) ? $button['url'] : "go('{$button['url']}');";
1464 
1465  if ($button['confirm'])
1466  {
1467  $link = "if (confirm('".jsSafe($button['confirm'])."')) $url; return false;";
1468  }
1469  else
1470  {
1471  $link = "$url; return false;";
1472  }
1473 
1474  $css = $this->buttonCSS;
1475  if ($button['cssClass'])
1476  {
1477  $css .= " ".$button['cssClass'];
1478  }
1479 
1480  echo "&nbsp;&nbsp;&nbsp;&nbsp;<input type='button' class='{$css}' onclick=\"$link\" value=\"{$button['text']}\"/>";
1481  }
1482 
1483  }
$buttonCSS
CSS Class to use for buttons.
Definition: auto_form.inc:50

◆ drawForm()

AutoForm::drawForm ( )

Renders the form to HTML.

Reimplemented in SearchForm, FilterForm, and SubordinateAutoForm.

Definition at line 1196 of file auto_form.inc.

1197  {
1198  if ($this->readOnlyForm) return $this->drawReadOnly();
1199 
1200  if ($this->onDrawStart)
1201  {
1202  if (call_user_func_array($this->onDrawStart, array($this)) === false)
1203  {
1204  return;
1205  }
1206  }
1207 
1208  $obj =& $this->data;
1209  $pk = $obj->getPrimaryKey();
1210 
1212  if ($submitLabel == "")
1213  {
1214  $submitLabel = ($obj->get($pk) != "" && $obj->get($pk) != 0) ? "Update ".$obj->prettifyClassName() : "Add ".$obj->prettifyClassName();
1215  }
1216 
1217  //echo "<!--\n";
1218  //print_r($this);
1219  //echo "\n-->\n";
1220 
1221  if (!$this->subordinate)
1222  {
1223  echo "<form id='{$this->id}' method='{$this->method}' action='{$this->action}' enctype='multipart/form-data'";
1224  if (!$this->ajaxSubmitHandler)
1225  {
1226  echo " onsubmit='return onSubmit{$this->id}(this);'";
1227  }
1228  else
1229  {
1230  echo " data-mode='ajax'";
1231  }
1232  echo ">\n";
1233  }
1234 
1235  if ($this->id)
1236  {
1237  echo "<input type='hidden' name='#FORMID#' value='{$this->id}'/>";
1238  }
1239 
1240  $csrfToken = $_SESSION["csrfToken"];
1241  if (!$csrfToken)
1242  {
1243  $csrfToken = plainGUID();
1244  $_SESSION["csrfToken"] = $csrfToken;
1245  }
1246 
1247  echo "<input type='hidden' name='#SESSIONTIE#' value='{$csrfToken}'/>\n";
1248 
1249  foreach(array_keys($this->hidden) as $hidden)
1250  {
1251  echo "<input id='{$this->id}_{$hidden}' type='hidden' name='$hidden' value='".htmlSafe($obj->get($hidden))."'/>\n";
1252  }
1253 
1254  if ($this->layout->externalErrorBox) $this->layout->errorBox();
1255 
1256  $this->layout->startUngrouped();
1257 
1258  if ($this->buttons_at_top && !$this->subordinate && !$this->hideButtons)
1259  {
1260  $this->layout->startButtonLine();
1261 
1262  $this->drawSubmitButtons($obj, $pk, $submitLabel);
1263 
1264  $this->drawButtons();
1265 
1266  $this->layout->endButtonLine();
1267  }
1268 
1269  if (!$this->layout->externalErrorBox) $this->layout->errorBox();
1270 
1271  if ($this->markRequiredFields && $this->validator->hasRequiredFields())
1272  {
1273  $this->layout->requiredFields($this->requiredFieldsText);
1274  }
1275 
1276  $this->renderAllFields($obj);
1277 
1278  if (!$this->subordinate && !$this->hideButtons)
1279  {
1280  $this->layout->startButtonLine();
1281 
1282  $this->drawSubmitButtons($obj, $pk, $submitLabel);
1283  $this->drawButtons();
1284 
1285  $this->layout->endButtonLine();
1286  }
1287 
1288  $this->layout->endUngrouped();
1289 
1290  $this->layout->finalizeLayout();
1291 
1292  if (!$this->subordinate)
1293  {
1294  echo "</form>\n";
1295  }
1296 
1297  if ($this->onDrawComplete)
1298  {
1299  call_user_func_array($this->onDrawComplete, array($this));
1300  }
1301  }
drawButtons()
Draws any additional buttons specified in the calling script.
Definition: auto_form.inc:1459
renderAllFields($obj)
Definition: auto_form.inc:1330
drawReadOnly()
Draws the form in read-only mode.
Definition: auto_form.inc:1489
$hidden
The hidden fields collection.
Definition: auto_form.inc:72
$submitLabel
Text to display on the form's submit button. If not specified defaut text will be generated based on ...
Definition: auto_form.inc:62
drawSubmitButtons($obj, $pk, $submitLabel)
Definition: auto_form.inc:1306
plainGUID()
Generates a version 4 GUID with no punctutation.
Definition: functions.inc:1954

◆ drawReadOnly()

AutoForm::drawReadOnly ( )

Draws the form in read-only mode.

This is most often used to display the details for a DataItem on a preview or details screen.

Reimplemented in SearchForm, and SubordinateAutoForm.

Definition at line 1489 of file auto_form.inc.

1490  {
1491  $this->readOnlyForm = true;
1492 
1493  $this->layout->startUngrouped();
1494 
1495  $obj =& $this->data;
1496 
1497  $this->renderAllFields($obj);
1498 
1499  $this->layout->endUngrouped();
1500 
1501  $this->layout->finalizeLayout();
1502  }

◆ drawSubmitButtons()

AutoForm::drawSubmitButtons (   $obj,
  $pk,
  $submitLabel 
)

Definition at line 1306 of file auto_form.inc.

1307  {
1308  $submitID = $this->id."_submitButton";
1309 
1310  if ($this->useLinkSubmit)
1311  {
1312  echo "<a id='{$submitID}' class='{$this->buttonCSS}' name='Submit' onclick='if (onSubmit{$this->id}(document.forms.{$this->id})) return document.forms.{$this->id}.submit(); else return false;'>$submitLabel</a>";
1313  }
1314  else
1315  {
1316  echo "<input type='submit' id='{$submitID}' class='{$this->buttonCSS}' name='Submit' value='$submitLabel' ondblclick='return false;'/>";
1317  }
1318 
1319  if ($obj->get($pk) && $this->allowDelete)
1320  {
1321  $deleteLabel = ($this->deleteLabel) ? $this->deleteLabel : "Delete this ".$obj->prettifyClassName();
1322  $deleteMessage = ($this->deleteMessage) ? $this->deleteMessage : "Are you sure you want to delete this ".$obj->prettifyClassName();
1323 
1324  echo "&nbsp;&nbsp;&nbsp;&nbsp;<input type='submit' class='{$this->buttonCSS}' name='{$this->id}_delete'
1325  value='$deleteLabel'
1326  onclick='return confirm(\"{$deleteMessage}\");'/>";
1327  }
1328  }
$deleteLabel
Text to display on the form's delete button. If not specified defaut text will be generated based on ...
Definition: auto_form.inc:64
$deleteMessage
Confirmation message to display when the form's delete button is pressed. If not specified defaut tex...
Definition: auto_form.inc:65

◆ dropdown()

AutoForm::dropdown (   $field,
  $label = "",
  $options = null,
  $onchange = null,
  $grouped = false 
)

Utility function to add a SelectFieldRenderer.

Parameters
string$fieldthe field name
string$labelthe label for the field
array$optionsassociative array of grouped options
See also
SelectFieldRenderer
Parameters
string$onchangeJavascript onchange handler function name (optional)
bool$groupedtrue if the options are grouped, false otherwise (default)

Definition at line 742 of file auto_form.inc.

743  {
744  return new SelectFieldRenderer($this, $field, $label, $options, $onchange, $grouped);
745  }

◆ getData()

AutoForm::getData ( )

Returns the target data item for the form.

Reimplemented in SubordinateAutoForm.

Definition at line 241 of file auto_form.inc.

242  {
243  return $this->data;
244  }

◆ getGroupCSSClass()

AutoForm::getGroupCSSClass (   $name)

Gets the CSS class for the specified group, if one has been set.

Parameters
string$namethe name of the group
Returns
string the CSS class applied to the group

Definition at line 879 of file auto_form.inc.

880  {
881  return array_key_exists($name, $this->groupCSSClasses) ? $this->groupCSSClasses[$name] : "";
882  }

◆ getGroupDescription()

AutoForm::getGroupDescription (   $name,
  $position = 'start' 
)

Retrieves the group description for the specified group.

Parameters
string$namethe name of the group
$positionwhether the description should appear at the 'start' or 'end' of the group

Definition at line 847 of file auto_form.inc.

848  {
849  $key = "{$name}:{$position}";
850  if (array_key_exists($key, $this->groupDescriptions)) return $this->groupDescriptions[$key];
851  return "";
852  }

◆ getRenderer()

AutoForm::getRenderer (   $field)

Retrieves the FieldRenderer object for the specified field.

You can use this to access the underlying field renderer for a given field and change the way it is rendered or processed.

Parameters
string$fieldthe name of the field for which to retrieve the FieldRenderer
Returns
FieldRenderer

Definition at line 512 of file auto_form.inc.

513  {
514  if (array_key_exists($field, $this->overrides))
515  {
516  if ($this->overrides[$field]['renderer']) return $this->overrides[$field]['renderer'];
517  }
518 
519  if (array_key_exists($field, $this->renderers))
520  {
521  return $this->renderers[$field];
522  }
523  else // JDG 2/13/2011 get renderer from additional field set
524  {
525  foreach($this->additional as $r)
526  {
527  $renderer = $r['renderer'];
528  $rField = $r['field'];
529  if(!$rField)
530  $rField = $renderer->field;
531  if($rField == $field)
532  return $renderer;
533  }
534  }
535 
536  trace("AutoForm::getRenderer(): Unknown field: $field", 2);
537  return null;
538  }
trace($msg, $lvl=3, $callStack=null)
Send output to the trace log.
Definition: functions.inc:1010

◆ getValidationEngine()

AutoForm::getValidationEngine ( )

Retrieve the validation engine for this AutoForm.

Reimplemented in SubordinateAutoForm.

Definition at line 340 of file auto_form.inc.

341  {
342  return $this->validator;
343  }
$validator
The ValidationEngine for this form.
Definition: auto_form.inc:80

◆ group()

AutoForm::group (   $name)

Define a field grouping.

Parameters
string$namethe legend to use for the group

Definition at line 801 of file auto_form.inc.

802  {
803  $group = (array_key_exists($name, $this->groups)) ? $this->groups[$name] : array();
804  for($i = 1; $i < func_num_args(); ++$i)
805  {
806  $group[] = func_get_arg($i);
807  }
808 
809  $this->groups[$name] = $group;
810  return $group;
811  }

◆ groupDescription()

AutoForm::groupDescription (   $name,
  $description,
  $position = 'start' 
)

Add a description block to a group.

This will be displayed within the group, after then title (if displayed) but before any fields.

Parameters
string$namethe name of the group
string$descriptionthe description to display for that group
string$positionwhether the description should appear at the 'start' or 'end' of the group

Definition at line 837 of file auto_form.inc.

838  {
839  $this->groupDescriptions["{$name}:{$position}"] = $description;
840  }

◆ groupedDropdown()

AutoForm::groupedDropdown (   $field,
  $label,
  $options,
  $onchange = null 
)

Utility function to add a SelectFieldRenderer with grouped options.

Parameters
string$fieldthe field name
string$labelthe label for the field
array$optionsassociative array of grouped options
See also
SelectFieldRenderer
Parameters
string$onchangeJavascript onchange handler function name (optional)
Returns
SelectFieldRenderer

Definition at line 755 of file auto_form.inc.

756  {
757  return $this->dropdown($field, $label, $options, $onchange, true);
758  }
dropdown($field, $label="", $options=null, $onchange=null, $grouped=false)
Utility function to add a SelectFieldRenderer.
Definition: auto_form.inc:742

◆ handlePartialSave()

AutoForm::handlePartialSave (   $success)

Definition at line 1655 of file auto_form.inc.

1656  {
1657  // Handle partial saves - return results via AJAX and exit immediately
1658  if ($this->allowPartialSave)
1659  {
1660  $headers = getallheaders();
1661  trace(print_r($headers, true), 3);
1662 
1663  if ($headers["X-Partial-Save"])
1664  {
1665  $result = array("status" => $success ? 'success' : 'error',
1666  "primary_key" => $this->data->getPrimaryKey(),
1667  "primary_key_value" => $this->data->get($this->data->getPrimaryKey()));
1668 
1669  if (!$success)
1670  {
1671  $result["error"] = $this->msg;
1672  }
1673 
1674  ajaxReturn(json_encode($result));
1675  }
1676  }
1677 
1678  return $success;
1679  }
ajaxReturn($msg=null)
Returns a string output and exits the script cleanly.
Definition: functions.inc:1783

◆ hasAdditional()

AutoForm::hasAdditional (   $field)

Check if this field exists as an additional field.

Definition at line 947 of file auto_form.inc.

948  {
949  foreach($this->additional as $r)
950  {
951  $renderer = $r['renderer'];
952  $rField = $r['field'];
953  trace("## $field == $rField", 3);
954  if($rField == $field)
955  return true;
956  }
957 
958  return $false;
959  }

◆ hide()

AutoForm::hide ( )

Call this method to hide one or more fields in the form's user interface.

For instance, calling hide("field1", "field3") would remove field1 and field3 from display when the form is rendered. Note that the values for these fields are still carried around with the form and saved to the database when the AutoForm saves the target DataItem. To prevent a field on the DataItem from being processed by the AutoForm at all, you should use an InclusionFilter or ExclusionFilter on the target DataItem.

Definition at line 624 of file auto_form.inc.

625  {
626  foreach(func_get_args() as $hidden)
627  {
628  $this->hidden[$hidden] = true;
629  }
630  }

◆ hideExcept()

AutoForm::hideExcept ( )

Call this method to hide all the fields in the form's user interface EXCEPT the fields specified.

For instance, calling hide("field1", "field3") would remove all the fields other than field1 and field3 when the form is rendered.
Note that the values for the hidden fields are still carried around with the form and saved to the database when the AutoForm saves the target DataItem. To prevent a field on the DataItem from being processed by the AutoForm at all, you should use an InclusionFilter or ExclusionFilter on the target DataItem.

Definition at line 641 of file auto_form.inc.

642  {
643  $exceptions = array_combine(func_get_args(), func_get_args());
644  foreach($this->data->getFields() as $name => $type)
645  {
646  if (!array_key_exists($name, $exceptions))
647  {
648  $this->hidden[$name] = true;
649  }
650  }
651  }

◆ hideLabel()

AutoForm::hideLabel ( )

Use this method to hide the labels for the specified fields in the form.

Definition at line 897 of file auto_form.inc.

898  {
899  foreach(func_get_args() as $naked)
900  {
901  $this->getRenderer($naked)->hideLabel = true;
902  }
903  }

◆ isHidden()

AutoForm::isHidden (   $field)

Check whether the specified field is hidden in the form.

Parameters
string$fieldthe name of the field
Returns
boolean true if the field has been hidden, false otherwise.

Definition at line 658 of file auto_form.inc.

659  {
660  return array_key_exists($field, $this->hidden) ? $this->hidden[$field] : false;
661  }

◆ isReadOnly()

AutoForm::isReadOnly (   $field)

Determine whether the specified field is being displayed read-only.

Parameters
string$fieldthe name of the field
Returns
boolean true if read-only, false otherwise

Definition at line 923 of file auto_form.inc.

924  {
925  return $this->readonly[$field];
926  }

◆ isRequired()

AutoForm::isRequired (   $field)

Determine whether the specified field is a required field for the form.

Parameters
$fieldthe field to check
Returns
boolean true if the field is required to be filled in by the user, false if it is an optional field.

Definition at line 966 of file auto_form.inc.

967  {
968  return (array_search($field, $this->required) !== FALSE) ? true : false;
969  }

◆ load()

AutoForm::load (   $id)

Loads the underlying DataItem from the database, using the specified primary key value.

Parameters
integer$idthe value to use for the primary key

Definition at line 1556 of file auto_form.inc.

1557  {
1558  $this->data->load($id);
1559  }

◆ makeGroupCollapsible()

AutoForm::makeGroupCollapsible (   $name,
  $toggleControl 
)

Allows a group to be shown or hidden based on the value of another control.

Parameters
string$namethe name of the group
string$toggleControlthe field name of the toggling control

Definition at line 859 of file auto_form.inc.

860  {
861  $this->collapsibleGroups[$name] = $toggleControl;
862  }

◆ makeSubordinate()

AutoForm::makeSubordinate ( )

Set this AutoForm to be a subordinate form within a CompositeAutoForm.

Reimplemented in SubordinateAutoForm.

Definition at line 348 of file auto_form.inc.

349  {
350  $this->subordinate = true;
351  }

◆ match()

AutoForm::match (   $field,
  $title,
  $match,
  $matchTitle,
  $caseSensitive = true 
)

Specifies that two field values must match (as in a password/confirmation pair, for instance).

Parameters
string$fieldThe name of the first field that must match
string$title
string$matchThe name of the second field that must match
string$matchTitle
string$caseSensitivespecifies whether the match is case sensitive

Definition at line 1090 of file auto_form.inc.

1091  {
1092  $this->validator->add(new MatchValidator($field, $title, $match, $matchTitle, $caseSensitive));
1093  }
Tests whether two fields contain the same value.
Definition: validation.inc:814

◆ matchesSubmitted()

AutoForm::matchesSubmitted ( )

Determine if this form is the one that was submitted.

Useful for managing pages with multiple forms.

Definition at line 1187 of file auto_form.inc.

1188  {
1189  return (isset($_POST["#FORMID#"]) && $_POST["#FORMID#"] == $this->id);
1190  }

◆ override()

AutoForm::override (   $field,
  $label = "",
  $renderer = null 
)

Overrides the defaults for the specifed form field, providing a new label and/or FieldRenderer.

Parameters
string$fieldthe name of the field that is to be overridden
string$labelthe new text to use for the label for the specified field (null or "" to use the default label).
FieldRenderer$rendererthe FieldRenderer-derived object to use in place of the default renderer for the specified field.

Definition at line 549 of file auto_form.inc.

550  {
551  if (!isset($this->overrides[$field]))
552  {
553  $this->overrides[$field] = array('label' => $label, 'renderer' => $renderer);
554  }
555  else
556  {
557  if ($label) $this->overrides[$field]['label'] = $label;
558  if ($renderer) $this->overrides[$field]['renderer'] = $renderer;
559  }
560  }

◆ overrideType()

AutoForm::overrideType (   $field,
  $type,
  $label = "" 
)

Override the default type for the specified form field, providing a FieldRenderer based on the supplied type (and optionally also override the field label)

Parameters
string$fieldthe name of the field that is to be overridden
string$typethe field type to use as the override
string$labelthe new text to use for the label for the specified field (null or "" to use the default label).

Definition at line 569 of file auto_form.inc.

570  {
571  if ($type == "Timestamp") return; // No field renderer required for this type
572 
573  if (array_key_exists($type, AutoForm::$fieldRendererMap))
574  {
575  $renderer = new AutoForm::$fieldRendererMap[$type]($this, $field);
576  $this->override($field, $label, $renderer);
577  return;
578  }
579 
580  throw new FakoliException("AutoForm::createRenderer(): Unknown type '$type'");
581  }

◆ partialSaveButton()

AutoForm::partialSaveButton (   $containerID,
  $label = "Save" 
)

Activate partial saves for this form.

A control will be added to the page that will allow users to save their progress without fully submitting the form. This is useful for long forms that required large amounts of text entry.

Parameters
string$containerIDDOM ID of the element that will contain the partial save button
string$labelText to display on the partial save button

Definition at line 1176 of file auto_form.inc.

1177  {
1178  $this->allowPartialSave = true;
1179  $this->partialSaveContainerID = $containerID;
1180  $this->partialSaveLabel = $label;
1181  }

◆ password()

AutoForm::password (   $field,
  $title 
)

Adds a password validator to the specified field.

Parameters
string$fieldThe name of the field.
stringThe title of the field

Definition at line 1101 of file auto_form.inc.

1102  {
1103  $this->validator->add(new PasswordValidator($field, $title, $this->id));
1104  }

◆ patchUpReferences()

AutoForm::patchUpReferences ( )
Deprecated:

Attempt to patch up references in the data model to cope with PHP 4's insane object reference semantics. PHP 4 is now no longer actively supported by this framework, so this method is deprecated.

Definition at line 1760 of file auto_form.inc.

1761  {
1762  // Hack for PHP4 compatibility
1763  // Due to the indescribable brain-death that is PHP4's object reference semantics,
1764  // we have to resort to this method to try and ensure consistency within the form's
1765  // constituent objects. Oh, well.
1766 
1767  if (substr(phpVersion(), 0, 2) == "4.")
1768  {
1769  foreach(array_keys($this->renderers) as $renderer)
1770  {
1771  $this->renderers[$renderer]->parent =& $this;
1772  }
1773  foreach(array_keys($this->overrides) as $override)
1774  {
1775  $this->overrides[$override]["renderer"]->parent =& $this;
1776  }
1777  }
1778  }

◆ postProcessFields()

AutoForm::postProcessFields (   $pk,
  $filter 
)

Definition at line 1705 of file auto_form.inc.

1706  {
1707  foreach (array_keys($this->fields) as $field)
1708  {
1709  if ($field != $pk && !array_key_exists($field, $this->hidden) &&
1710  !($filter && $filter->isExcluded($field)))
1711  {
1712  $renderer = $this->getRenderer($field);
1713  if ($renderer)
1714  {
1715  $renderer->postProcess($field);
1716  }
1717  }
1718  }
1719 
1720  foreach($this->additional as $r)
1721  {
1722  $renderer = $r['renderer'];
1723  $field = $r['field'];
1724 
1725  $renderer->postProcess($field);
1726  }
1727  }

◆ preProcessFields()

AutoForm::preProcessFields (   $pk,
  $filter 
)

Definition at line 1681 of file auto_form.inc.

1682  {
1683  foreach (array_keys($this->fields) as $field)
1684  {
1685  if ($field != $pk && !array_key_exists($field, $this->hidden) &&
1686  !($filter && $filter->isExcluded($field)))
1687  {
1688  $renderer = $this->getRenderer($field);
1689  if ($renderer)
1690  {
1691  $renderer->preProcess($field);
1692  }
1693  }
1694  }
1695 
1696  foreach($this->additional as $r)
1697  {
1698  $renderer = $r['renderer'];
1699  $field = $r['field'];
1700 
1701  $renderer->preProcess($field);
1702  }
1703  }

◆ prettifyFieldName()

AutoForm::prettifyFieldName (   $field)

Generates a human-readable label from the given field name.

If an explicit alias has been specified using the alias() method, then that is returned. If not, a simple set of text replacements is performed.

Parameters
string$fieldthe field to prettify
Returns
string

Definition at line 1512 of file auto_form.inc.

1513  {
1514  if (array_key_exists($field, $this->overrides))
1515  {
1516  $l = $this->overrides[$field]['label'];
1517  if ($l != "") return $l;
1518  }
1519 
1520  $field = preg_replace("/([a-z])([A-Z0-9])/", "$1 $2", $field);
1521  $field = str_replace("_", " ", $field);
1522 
1523  switch($this->capitalizationMode)
1524  {
1525  case "lower":
1526 
1527  $field = strtolower($field);
1528  break;
1529 
1530  case "upper":
1531 
1532  $field = strtoupper($field);
1533  break;
1534 
1535  case "first":
1536 
1537  $field = ucfirst($field);
1538  break;
1539 
1540  case "word":
1541  default:
1542 
1543  $field = ucwords($field);
1544  break;
1545  }
1546 
1547  return $field;
1548  }

◆ radio()

AutoForm::radio (   $field,
  $label,
  $options,
  $onchange = null 
)

Utility function to add a RadioButtonFieldRenderer.

Parameters
string$fieldthe field name
string$labelthe label for the field
array$optionsassociative array of grouped options
See also
RadioButtonFieldRenderer
Parameters
string$onchangeJavascript onchange handler function name (optional)
Returns
RadioButtonFieldRenderer

Definition at line 768 of file auto_form.inc.

769  {
770  return new RadioButtonFieldRenderer($this, $field, $label, $options);
771  }
Field renderer for data fields that must be displayed as a list of choices.

◆ range()

AutoForm::range (   $field,
  $min,
  $max,
  $message = null 
)

Adds a range validator to the specified field.

Definition at line 1073 of file auto_form.inc.

1074  {
1075  if ($this->data->hasField($field))
1076  {
1077  $this->validator->add(new RangeValidator($field, $this->prettifyFieldName($field), $min, $max, $message));
1078  }
1079  }
RangeValidator class.

◆ readonly()

AutoForm::readonly ( )

Call this method to make one or more fields read-only in the form's user interface.

For instance, calling readonly("field1", "field3") would cause field1 and field3 to be rendered read-only.

Definition at line 910 of file auto_form.inc.

911  {
912  foreach(func_get_args() as $readonly)
913  {
914  $this->readonly[$readonly] = true;
915  }
916  }
$readonly
The read-only fields collection.
Definition: auto_form.inc:75

◆ regexp()

AutoForm::regexp (   $field,
  $expr,
  $message 
)

Validate the user input for the specified field against a regular expression, outputting the supplied message if the entered value does not match.

This can be used to provide general format-based validation for fields.

Parameters
string$fieldthe field to be validated
string$exprthe Regular Expression against which to validate
string$messagethe message to display if the match fails.

Definition at line 1014 of file auto_form.inc.

1015  {
1016  if ($this->data->hasField($field))
1017  {
1018  $this->validator->add(new RegularExpressionValidator($field, $this->prettifyFieldName($field), $expr, $message));
1019  }
1020  }
Tests wheteher a field's value matches the supplied regular expression.
Definition: validation.inc:950

◆ registerFieldRendererClass()

static AutoForm::registerFieldRendererClass (   $type,
  $rendererClass 
)
static

Registers a custom type-to-renderer mapping.

Parameters
string$typethe type identifier
string$rendererClassthe class name of the renderer to handle fields of this type

Definition at line 299 of file auto_form.inc.

300  {
301  AutoForm::$fieldRendererMap[$type] = $rendererClass;
302  }

◆ related()

AutoForm::related (   $class,
  $constraint = "",
  $format = null,
  $field = null,
  $label = null,
  $allowAdd = false,
  $allowNone = true 
)

Utility function to add a RelatedItemSelectFieldRender.

Definition at line 697 of file auto_form.inc.

698  {
699  $obj = new $class;
700  if (!$format) $format = $obj->default_format;
701  if (!$field) $field = $obj->getPrimaryKey();
702  if (!$label) $label = $obj->prettifyClassName();
703 
704  if (!$this->data->hasField($field))
705  {
706  throw new FakoliException(get_class($this->data)." has no field '{$field}'");
707  }
708 
709  if (!$format)
710  {
711  throw new FakoliException("Format not specified for related $class");
712  }
713 
714  return new RelatedItemSelectFieldRenderer($this, $field, $label, $class, $constraint, $format, $obj->getPrimaryKey(), $allowAdd, $allowNone);
715  }

◆ remove()

AutoForm::remove ( $obj)

Definition at line 1729 of file auto_form.inc.

1730  {
1731  $obj->delete();
1732  }

◆ removeGroup()

AutoForm::removeGroup (   $name)

Remove the specified field grouping from the form.

Any fields within the group will be displayed ungrouped if they are not hidden.

Parameters
string$namethe legend of the group

Definition at line 889 of file auto_form.inc.

890  {
891  unset($this->groups[$name]);
892  }

◆ renderAdditionalFields()

AutoForm::renderAdditionalFields (   $obj)

Reimplemented in SearchForm.

Definition at line 1431 of file auto_form.inc.

1432  {
1433  foreach($this->additional as $r)
1434  {
1435  $renderer = $r['renderer'];
1436  // JDG 5/24/11 - fix get field name
1437  $field = $r['field'];
1438  if(!$field)
1439  $field = $renderer->field;
1440 
1441  if(array_key_exists($field, $this->renderedFields))
1442  continue;
1443 
1444  if ($this->readonly[$field] || $this->readOnlyForm)
1445  {
1446  $renderer->renderReadOnly($field);
1447  }
1448  else
1449  {
1450  $renderer->renderField($field);
1451  }
1452  }
1453  }

◆ renderAllFields()

AutoForm::renderAllFields (   $obj)

Definition at line 1330 of file auto_form.inc.

1331  {
1332  $this->renderedFields = array();
1333 
1334  if($this->additional_at_top)
1335  $this->renderAdditionalFields($obj);
1336  $this->renderFields($obj);
1337  if(!$this->additional_at_top)
1338  $this->renderAdditionalFields($obj);
1339  }
renderFields($obj)
Definition: auto_form.inc:1346
renderAdditionalFields($obj)
Definition: auto_form.inc:1431

◆ renderFields()

AutoForm::renderFields (   $obj)

Definition at line 1346 of file auto_form.inc.

1347  {
1348  $filter = $obj->getFilter();
1349 
1350  if (count($this->groups) > 0)
1351  {
1352  $this->layout->endUngrouped();
1353 
1354  foreach($this->groups as $legend => $fields)
1355  {
1356  $collapsible = array_key_exists($legend, $this->collapsibleGroups);
1357  if ($collapsible)
1358  {
1359  $cf = $this->collapsibleGroups[$legend];
1360  //AJG: Allow direct specification of boolean for collapsed group state
1361  $collapsed = is_bool($cf) ? $cf : !$this->data->get($cf);
1362  }
1363 
1364  $this->layout->startGroup($legend, $collapsible, $collapsed);
1365 
1366  foreach($fields as $field)
1367  {
1368  if ($field != $pk && !array_key_exists($field, $this->hidden) && !array_key_exists($field, $this->renderedFields) &&
1369  ($this->hasAdditional($field) || !($filter && $filter->isExcluded($field))))
1370  {
1371  $this->renderOneField($field);
1372  }
1373  }
1374 
1375  $this->layout->endGroup();
1376  }
1377 
1378  $this->layout->startUngrouped();
1379 
1380  }
1381 
1382  foreach($this->fieldOrder as $field)
1383  {
1384  if ($field != $pk && !array_key_exists($field, $this->hidden) && !array_key_exists($field, $this->renderedFields) &&
1385  ($this->hasAdditional($field) || !($filter && $filter->isExcluded($field))))
1386  {
1387  $this->renderOneField($field);
1388  }
1389  }
1390 
1391  foreach(array_keys($this->fields) as $field)
1392  {
1393  if ($field != $pk && !array_key_exists($field, $this->hidden) && !array_key_exists($field, $this->renderedFields) &&
1394  ($this->hasAdditional($field) || !($filter && $filter->isExcluded($field))))
1395  {
1396  $this->renderOneField($field);
1397  }
1398  }
1399  }
hasAdditional($field)
Check if this field exists as an additional field.
Definition: auto_form.inc:947
$fields
Local field cache.
Definition: auto_form.inc:111
renderOneField($field, $renderScript=false)
Definition: auto_form.inc:1401

◆ renderOneField()

AutoForm::renderOneField (   $field,
  $renderScript = false 
)

Definition at line 1401 of file auto_form.inc.

1402  {
1403  $renderer = $this->getRenderer($field);
1404 
1405  if ($renderer)
1406  {
1407  if ($this->readonly[$field] || $this->readOnlyForm)
1408  {
1409  if (!$this->hideEmptyFields || !$this->data->hasField($field) || $this->data->get($field))
1410  {
1411  $renderer->renderReadOnly($field);
1412  }
1413  }
1414  else
1415  {
1416  if ($renderScript)
1417  {
1418  $renderer->renderScript($field);
1419  }
1420  $renderer->renderField($field);
1421  }
1422 
1423  $this->renderedFields[$field] = true;
1424  }
1425  }

◆ required()

AutoForm::required ( )

Call this method to mark one or more fields as being required fields.

These fields will be assigned validators to ensure that the user enters a value for each required field. For instance, calling required("field1", "field3") would cause field1 and field3 to be required fields.

Definition at line 933 of file auto_form.inc.

934  {
935  foreach(func_get_args() as $required)
936  {
937  if ($this->data->hasField($required) || $this->hasAdditional($required))
938  {
939  array_push($this->required, $required);
940  }
941  }
942  }

◆ requiredIfChecked()

AutoForm::requiredIfChecked (   $field,
  $checkbox,
  $fieldTitle = "",
  $checkboxTitle = "",
  $message = "" 
)

Make a field required if a given checkbox is checked.

Parameters
string$fieldthe field to be validated
string$checkboxthe checkbox controlling whether the field is required
string$messagethe message to display if validation fails.

Definition at line 977 of file auto_form.inc.

978  {
979  if ($this->data->hasField($field))
980  {
981  $this->validator->add(new RequiredIfCheckedValidator($field, $checkbox,
982  $fieldTitle ? $fieldTitle : $this->prettifyFieldName($field),
983  $checkboxTitle ? $checkboxTitle : $this->prettifyFieldName($checkbox), $message));
984  }
985  }

◆ requiredSubSelect()

AutoForm::requiredSubSelect (   $field,
  $fieldTitle,
  $subFieldTitle = "",
  $message = "" 
)

Make a subselect field required.

The main option must always be selected. If there is a sub-select option, that must also be selected.

Parameters
string$fieldthe field to be validated
string$fieldTitlecustom human-readable name for the field
string$subFieldTitlecustom human-readable name for the sub-field
string$messagethe message to display if validation fails.

Definition at line 995 of file auto_form.inc.

996  {
997  if ($this->data->hasField($field))
998  {
999  $this->validator->add(new SubSelectFieldRequiredValidator($field,
1000  $fieldTitle ? $fieldTitle : $this->prettifyFieldName($field),
1001  $subFieldTitle, $message));
1002  }
1003  }

◆ save()

AutoForm::save ( )

Saves the posted values to the database.

Returns
boolean - true if the save was successful.

Reimplemented in SubordinateAutoForm.

Definition at line 1566 of file auto_form.inc.

1567  {
1568  $this->patchUpReferences();
1569 
1570  $this->configureValidators();
1571 
1572  $obj =& $this->data;
1573  $obj->fromPOST();
1574 
1575  $filter = $obj->getFilter();
1576  $pk = $obj->getPrimaryKey();
1577 
1578  if (isset($_POST["#FORMID#"]))
1579  {
1580  trace("FORM ID: {$this->id} - {$_POST["#FORMID#"]}", 3);
1581  $this->id = $_POST["#FORMID#"];
1582  }
1583 
1584  if (!isset($_POST["#SESSIONTIE#"]) || $_POST["#SESSIONTIE#"] != $_SESSION["csrfToken"])
1585  {
1586  trace("Invalid Session Token - {$_POST["#SESSIONTIE#"]} vs {$_SESSION["csrfToken"]}", 3);
1587  throw new FakoliException("Invalid Session Token");
1588  }
1589 
1590  if ($_POST["{$this->id}_delete"])
1591  {
1592  if(!$this->onDelete)
1593  {
1594  $obj->delete(); // no callback function defined
1595  }
1596  else
1597  {
1598  call_user_func_array($this->onDelete, array($obj));
1599  }
1600  $this->deleted = true;
1601  return true;
1602  }
1603 
1604  $this->msg = $this->validator->validate();
1605  if ($this->msg != "") return $this->handlePartialSave(false);
1606 
1607  $this->preProcessFields($pk, $filter);
1608 
1609  // Call the onInsertPreProcess callback if the primary key of the target object is not set (i.e. is a new object)
1610 
1611  if (!$this->data->getPrimaryKeyValue() & $this->onInsertPreProcess)
1612  {
1613  if (call_user_func_array($this->onInsertPreProcess, array($this)) === false)
1614  {
1615  return $this->handlePartialSave(false);
1616  }
1617  }
1618 
1619  // Call the onSavePreProcess callback if set
1620 
1621  if ($this->onSavePreProcess)
1622  {
1623  if (call_user_func_array($this->onSavePreProcess, array($this)) === false)
1624  {
1625  return $this->handlePartialSave(false);
1626  }
1627  }
1628 
1629  // Defer to the customSaveHandler if it has been defined, otherwise tell the target object to save itself
1630 
1631  if ($this->customSaveHandler)
1632  {
1633  if (!call_user_func_array($this->customSaveHandler, array($this)))
1634  {
1635  return $this->handlePartialSave(false);
1636  }
1637  }
1638  else
1639  {
1640  $obj->save();
1641  }
1642 
1643  $this->postProcessFields($pk, $filter);
1644 
1645  // onComplete event is fired once all processing has been completed
1646 
1647  if ($this->onSaveComplete)
1648  {
1649  call_user_func_array($this->onSaveComplete, array($this));
1650  }
1651 
1652  return $this->handlePartialSave(true);
1653  }
configureValidators()
Definition: auto_form.inc:353
postProcessFields($pk, $filter)
Definition: auto_form.inc:1705
handlePartialSave($success)
Definition: auto_form.inc:1655
patchUpReferences()
Definition: auto_form.inc:1760
preProcessFields($pk, $filter)
Definition: auto_form.inc:1681

◆ setDataSet()

AutoForm::setDataSet (   $params)

Reimplemented in SubordinateAutoForm.

Definition at line 246 of file auto_form.inc.

247  {
248  $this->dataSet = $params;
249  }

◆ setFieldOrder()

AutoForm::setFieldOrder ( )

Override the display order for ungrouped field.

Definition at line 263 of file auto_form.inc.

264  {
265  for($i = 0; $i < func_num_args(); ++$i)
266  {
267  $this->fieldOrder[] = func_get_arg($i);
268  }
269  }

◆ setGroupCSSClass()

AutoForm::setGroupCSSClass (   $name,
  $cssClass 
)

Sets a specific CSS class on the specified CSS group.

Parameters
string$namethe name of the group
string$cssClassthe CSS class to apply to the group

Definition at line 869 of file auto_form.inc.

870  {
871  $this->groupCSSClasses[$name] = $cssClass;
872  }

◆ setLayout()

AutoForm::setLayout (   $layout)

Override the default layout manager.

Definition at line 255 of file auto_form.inc.

256  {
257  $this->layout = $layout;
258  }
$layout
Layout handler object.
Definition: auto_form.inc:125

◆ toggle()

AutoForm::toggle (   $field,
  $label = "",
  $ragged = false 
)

Utility function to create a ToggleFieldRenderer.

Parameters
string$fieldthe field name
string$labelthe label for the field

Definition at line 789 of file auto_form.inc.

790  {
791  $renderer = new ToggleFieldRenderer($this, $ragged);
792  $this->override($field, $label, $renderer);
793  return $renderer;
794  }
Field renderer for boolean data fields.

◆ unique()

AutoForm::unique ( )

Adds a uniqueness validator to the specified field(s).

This is a server-side only validator that checks that the supplied value for the field is not present for any row in the underlying database table.

Definition at line 1048 of file auto_form.inc.

1049  {
1050  for($i = 0; $i < func_num_args(); $i += 2)
1051  {
1052  $field = func_get_arg($i);
1053  $message = func_get_arg($i + 1);
1054 
1055  if ($this->data->hasField($field))
1056  {
1057  $this->validator->add(new UniqueValidator($field, $this->prettifyFieldName($field), $this->data, $message));
1058  }
1059  }
1060  }
Uniqueness Validator.
Definition: validation.inc:742

◆ uniqueWithConstraint()

AutoForm::uniqueWithConstraint (   $field,
  $message,
  $constraint = "" 
)

Definition at line 1062 of file auto_form.inc.

1063  {
1064  if ($this->data->hasField($field))
1065  {
1066  $this->validator->add(new UniqueValidator($field, $this->prettifyFieldName($field), $this->data, $message, $constraint));
1067  }
1068  }

◆ validate()

AutoForm::validate ( )

Validate the posted values for the form.

This is performed automatically when calling AutoForm::save(), but sometimes it might be necessary to validate the form values manually (for instance, you might need to perform some destructive database operations prior to calling AutoForm::save(), but only if you know the form to be valid).

Any validation errors encountered are stored in the form, and will be displayed when the form is subsequently rendered.

Returns
true if the form is valid, false otherwise.

Definition at line 1746 of file auto_form.inc.

1747  {
1748  $this->patchUpReferences();
1749  $this->msg = $this->validator->validate();
1750  return ($this->msg == "");
1751  }

◆ writeScript()

AutoForm::writeScript ( )

This method writes any Javascript code that will be required for the generated form to operate, including code for Rich Text Editors, Date Pickers and field validation.

Returns
string the script required for the generated form.

Reimplemented in SearchForm, FilterForm, and SubordinateAutoForm.

Definition at line 374 of file auto_form.inc.

375  {
376  $this->patchUpReferences();
377 
378  ob_start();
379 
380  $this->configureValidators();
381 
382  $obj =& $this->data;
383  $filter = $obj->getFilter();
384  $pk = $obj->getPrimaryKey();
385 
386  $script = "";
387  foreach(array_keys($this->fields) as $field)
388  {
389  if ($field != $pk && !($filter && $filter->isExcluded($field)))
390  {
391  $renderer = $this->getRenderer($field);
392  if ($renderer)
393  {
394  $renderer->renderScript($field);
395  }
396  }
397  }
398 
399  foreach($this->additional as $r)
400  {
401  $r['renderer']->renderScript($r['field']);
402  }
403 
404  echo "<script type='text/javascript'>\n";
405  echo $this->validator->writeScript();
406  echo "\n\n";
407  echo "function onSubmit{$this->id}(form)\n{\n";
408 
409  echo "\tif (validate_{$this->id} != null && !validate_{$this->id}(form)) return false;\n";
410 
411  foreach(array_keys($this->fields) as $field)
412  {
413  if ($field != $pk && !($filter && $filter->isExcluded($field)))
414  {
415  $renderer = $this->getRenderer($field);
416  if ($renderer)
417  {
418  $renderer->renderOnSubmitHandler($field);
419  }
420  }
421  }
422 
423  foreach($this->additional as $r)
424  {
425  $r['renderer']->renderOnSubmitHandler($r['field']);
426  }
427 
428  if ($this->onSubmitHandler)
429  {
430  echo "\t if (!{$this->onSubmitHandler}(form)) return false;\n;";
431  }
432 
433  if ($this->confirmPrompt)
434  {
435  echo "\t if (!confirm(\"".jsSafe($this->confirmPrompt)."\")) return false;\n";
436  }
437 
438  if ($this->interstitialMessage)
439  {
440  echo "\tinterstitial('".jsSafe($this->interstitialMessage)."', '".jsSafe($this->interstitialSpinner)."');\n;";
441  }
442 
443  echo "\treturn true;\n}\n\n";
444 
445  echo "\twindow.addEvent('domready', function() {\n";
446 
447  if ($this->allowPartialSave && $this->partialSaveContainerID)
448  {
449  $managerOptions = "{partialSaveContainer: '{$this->partialSaveContainerID}', partialSaveLabel: '{$this->partialSaveLabel}'}";
450  }
451  else
452  {
453  $managerOptions = "{}";
454  }
455 
456  echo "\tnew AutoFormManager('{$this->id}', {$managerOptions});\n";
457 
458  if ($this->ajaxSubmitHandler && !$this->readOnlyForm)
459  {
460 ?>
461  document.id('<?echo $this->id?>').iFrameFormRequest(
462  {
463  'onRequest': function() { return onSubmit<?echo $this->id?>(document.id('<?echo $this->id?>')); },
464  'onComplete': <?echo $this->ajaxSubmitHandler; ?>,
465  'onFailure': <?echo $this->ajaxFailureHandler; ?>
466  });
467 <?
468 
469  }
470 
471  // Add collapsible group handlers
472 
473  foreach($this->collapsibleGroups as $group => $toggle)
474  {
475  if (is_bool($toggle))
476  {
477  $groupID = $this->id . "_" . codify($group) . "_group";
478  echo "\tdocument.id('$groupID').getElement('legend').addEvent('click', function(e) { var g = document.id('$groupID'); if (g.hasClass('collapsed')) { g.removeClass('collapsed'); g.addClass('expanded'); } else { g.removeClass('expanded'); g.addClass('collapsed'); } });\n";
479  echo "\tdocument.id('$groupID').addClass('toggleSelf');\n";
480  }
481  else
482  {
483  $groupID = $this->id . "_" . codify($group) . "_group";
484  $toggleID = $this->id . "_" . $toggle;
485 
486  $renderer = $this->getRenderer($toggle);
487  if ($renderer instanceof BooleanFieldRenderer)
488  {
489  echo "\tdocument.id('$toggleID').addEvent('click', function(e) { AutoFormManager.toggleGroup('$groupID', this.checked); });\n";
490  }
491  else
492  {
493  echo "\tdocument.id('$toggleID').addEvent('change', function(e) { AutoFormManager.toggleGroup('$groupID', (this.value != '0')); });\n";
494  }
495  }
496  }
497  echo "\t});\n";
498  echo "</script>\n";
499  $script = ob_get_contents();
500  ob_end_clean();
501  return $script;
502  }
$ajaxSubmitHandler
JavaScript Callback for AJAX Submit mode - called on success.
Definition: auto_form.inc:103
$ajaxFailureHandler
JavaScript Callback for AJAX Submit mode - called on failure.
Definition: auto_form.inc:104
Field renderer for boolean data fields.
codify($name)
Takes a text string and converts it into a code-compliant format, suitable for use as a variable name...
Definition: functions.inc:1399
jsSafe($str, $escapeEntities=false)
Utility function to escape a string correctly for use in a Javascript client-side call.
Definition: functions.inc:434

Member Data Documentation

◆ $action

AutoForm::$action = ""

Action URL for submitting the form. Generally this can be left blank to submit back to the same page.

Definition at line 68 of file auto_form.inc.

◆ $additional

AutoForm::$additional = array()

The additional (pseudo) fields collection.

Definition at line 73 of file auto_form.inc.

◆ $additional_at_top

AutoForm::$additional_at_top = false

whether additional fields are rendered above the datamodel's field list; if false, then rendered below

Definition at line 74 of file auto_form.inc.

◆ $ajaxFailureHandler

AutoForm::$ajaxFailureHandler = false

JavaScript Callback for AJAX Submit mode - called on failure.

Definition at line 104 of file auto_form.inc.

◆ $ajaxSubmitHandler

AutoForm::$ajaxSubmitHandler = false

JavaScript Callback for AJAX Submit mode - called on success.

Definition at line 103 of file auto_form.inc.

◆ $allowDelete

AutoForm::$allowDelete = false

If true, the form will display a delete button if editing an existing item.

Definition at line 63 of file auto_form.inc.

◆ $allowPartialSave

AutoForm::$allowPartialSave = false

Whether to allow partial (i.e. in-progress) saves via AJAX.

Definition at line 128 of file auto_form.inc.

◆ $annotations

AutoForm::$annotations = array()

The field annotations collection.

Definition at line 76 of file auto_form.inc.

◆ $buttonAlignment

AutoForm::$buttonAlignment = "left"

Default Form button alignment.

Definition at line 56 of file auto_form.inc.

◆ $buttonCSS

AutoForm::$buttonCSS = ""

CSS Class to use for buttons.

Definition at line 50 of file auto_form.inc.

◆ $buttonLineCSS

AutoForm::$buttonLineCSS = "submit"

CSS Class to use for the button line (container for form buttons)

Definition at line 51 of file auto_form.inc.

◆ $buttons

AutoForm::$buttons = array()

The custom buttons collection.

Definition at line 77 of file auto_form.inc.

◆ $buttons_at_top

AutoForm::$buttons_at_top = false

Definition at line 102 of file auto_form.inc.

◆ $capitalizationMode

AutoForm::$capitalizationMode = "word"

Capitalization to be used for labels. Can be 'lower', 'upper', 'first' or 'word'.

Definition at line 60 of file auto_form.inc.

◆ $checkboxCSS

AutoForm::$checkboxCSS = ""

CSS Class to use for checkbox fields.

Definition at line 53 of file auto_form.inc.

◆ $collapsibleGroups

AutoForm::$collapsibleGroups = array()

List of collapsible groups and their default states.

Definition at line 114 of file auto_form.inc.

◆ $componentPath

AutoForm::$componentPath ="/fakoli"

Definition at line 55 of file auto_form.inc.

◆ $confirmPrompt

AutoForm::$confirmPrompt = null

Specify a confirmation message. This will be shown to the user to have them confirm the form submission after the submit button is pressed.

Definition at line 97 of file auto_form.inc.

◆ $customSaveHandler

AutoForm::$customSaveHandler = null

Use this field to override the default save behavior of your form.

Definition at line 99 of file auto_form.inc.

◆ $default_layout

AutoForm::$default_layout = "table"

Definition at line 126 of file auto_form.inc.

◆ $deleteLabel

AutoForm::$deleteLabel = ""

Text to display on the form's delete button. If not specified defaut text will be generated based on the target DataItem.

Definition at line 64 of file auto_form.inc.

◆ $deleteMessage

AutoForm::$deleteMessage = ""

Confirmation message to display when the form's delete button is pressed. If not specified defaut text will be generated based on the target DataItem.

Definition at line 65 of file auto_form.inc.

◆ $fieldOrder

AutoForm::$fieldOrder = array()

The order in which to display ungrouped fields.

Definition at line 78 of file auto_form.inc.

◆ $fieldRendererMap

AutoForm::$fieldRendererMap
static
Initial value:
= array (
'String' => StringFieldRenderer,
'HTML' => HTMLFieldRenderer,
'Date' => DateFieldRenderer,
'DateTime' => DateTimeFieldRenderer,
'Number' => NumberFieldRenderer,
'Currency' => CurrencyFieldRenderer,
'Currency3' => Currency3FieldRenderer,
'Boolean' => BooleanFieldRenderer,
'TimeZone' => TimezoneFieldRenderer,
'Password' => PasswordFieldRenderer,
'Text' => TextFieldRenderer,
'Time' => TimeFieldRenderer,
'Rating' => RatingFieldRenderer,
'ZipCode' => ZipCodeFieldRenderer,
'PhoneNumber' => PhoneNumberFieldRenderer,
'URL' => URLFieldRenderer,
'DateOfBirth' => DateOfBirthFieldRenderer,
'CreditCardNumber' => CreditCardNumberFieldRenderer,
'Signature' => SignatureFieldRenderer,
'Color' => ColorFieldRenderer
)
Field renderer for boolean data fields.
Use Currency3 if you want to have 3 decimal places displayed.
Field renderer for currency data fields.
Field renderer for date data fields.
Field renderer for date of birth data fields.
Field renderer for date data fields.
Field renderer for HTML data fields.
Field renderer for numeric data fields.
Field renderer for password data fields.
Field renderer for zipcode data fields.
Field renderer for numeric rating data fields.
Provides a very simple digital signature implementation.
Field renderer for string data fields.
Field renderer for text data fields.
Field renderer for time data fields.
Field renderer for zipcode data fields.

Provides the mapping from Type identifier to FieldRenderer.

Definition at line 134 of file auto_form.inc.

◆ $fields

AutoForm::$fields

Local field cache.

Definition at line 111 of file auto_form.inc.

◆ $formCSS

AutoForm::$formCSS = ""

CSS Class to use for the table containing the form.

Definition at line 47 of file auto_form.inc.

◆ $groupCSSClasses

AutoForm::$groupCSSClasses = array()

Additional classes for specific groups.

Definition at line 118 of file auto_form.inc.

◆ $groupDescriptionCSS

AutoForm::$groupDescriptionCSS = "group_description"

CSS class for group description blocks.

Definition at line 117 of file auto_form.inc.

◆ $groupDescriptions

AutoForm::$groupDescriptions = array()

List of group descriptions.

Definition at line 115 of file auto_form.inc.

◆ $groups

AutoForm::$groups = array()

List of field groups.

Definition at line 113 of file auto_form.inc.

◆ $hidden

AutoForm::$hidden = array()

The hidden fields collection.

Definition at line 72 of file auto_form.inc.

◆ $hideButtons

AutoForm::$hideButtons = false

Set to true to hide form submission button line(s)

Definition at line 59 of file auto_form.inc.

◆ $hideEmptyFields

AutoForm::$hideEmptyFields = false

Specifies whether to hide empty fields when displaying a read-only form.

Definition at line 122 of file auto_form.inc.

◆ $HTMLEditorDefaultHeight

AutoForm::$HTMLEditorDefaultHeight = "200px"

Default height for Rich Text Editor controls.

Definition at line 85 of file auto_form.inc.

◆ $HTMLEditorDefaultWidth

AutoForm::$HTMLEditorDefaultWidth = "540px"

Default width for Rich Text Editor controls.

Definition at line 84 of file auto_form.inc.

◆ $HTMLEditorHideStyleBar

AutoForm::$HTMLEditorHideStyleBar = false

Flag to indicate that Rich Text Editors should be displayed with or without the style editing toolbar.

Definition at line 83 of file auto_form.inc.

◆ $inputCSS

AutoForm::$inputCSS = ""

CSS Class to use for input fields.

Definition at line 52 of file auto_form.inc.

◆ $interstitialMessage

AutoForm::$interstitialMessage = null

Specifies the message to display in an interstitial while the form is being submitted.

Definition at line 108 of file auto_form.inc.

◆ $interstitialSpinner

AutoForm::$interstitialSpinner = '/fakoli/images/loader.gif'

Set this property to override the default interstitial spinner animation.

Definition at line 109 of file auto_form.inc.

◆ $labelCSS

AutoForm::$labelCSS = ""

CSS Class to use for label cells.

Definition at line 48 of file auto_form.inc.

◆ $layout

AutoForm::$layout

Layout handler object.

Definition at line 125 of file auto_form.inc.

◆ $markRequiredFields

AutoForm::$markRequiredFields = false

Set to true to add an asterisk after required field labels.

Definition at line 100 of file auto_form.inc.

◆ $method

AutoForm::$method = "POST"

HTTP method that will be used to submit the form.

Definition at line 67 of file auto_form.inc.

◆ $onDelete

AutoForm::$onDelete = ""

delete method name

Definition at line 98 of file auto_form.inc.

◆ $onDrawComplete

AutoForm::$onDrawComplete = null

Callback event handler that is fired just after the form been drawn.

Definition at line 91 of file auto_form.inc.

◆ $onDrawStart

AutoForm::$onDrawStart = null

Callback event handler that is fired just prior to drawing the form.

Definition at line 90 of file auto_form.inc.

◆ $onFormatLabel

AutoForm::$onFormatLabel = null

Label Processing hook.

Definition at line 101 of file auto_form.inc.

◆ $onInsertPreProcess

AutoForm::$onInsertPreProcess = null

Callback event handler that is fired after fields have been preprocessed, but before the data has been saved to the database as a new record.

Definition at line 93 of file auto_form.inc.

◆ $onSaveComplete

AutoForm::$onSaveComplete = null

Callback event handler that is fired after the AutoForm has finished saving data to the database.

Definition at line 95 of file auto_form.inc.

◆ $onSavePreProcess

AutoForm::$onSavePreProcess = null

Callback event handler that is fired after fields have been preprocessed, but before the data has been saved to the database.

Definition at line 94 of file auto_form.inc.

◆ $onSubmitHandler

AutoForm::$onSubmitHandler = null

Javascript Callback for user-defined onsubmit hook.

Definition at line 105 of file auto_form.inc.

◆ $overrides

AutoForm::$overrides = array()

The field overrides collection.

Definition at line 71 of file auto_form.inc.

◆ $partialSaveContainerID

AutoForm::$partialSaveContainerID

DOM ID for the element that will contain the partial save button.

Definition at line 129 of file auto_form.inc.

◆ $partialSaveLabel

AutoForm::$partialSaveLabel = "Save"

Label text for the partial save button.

Definition at line 130 of file auto_form.inc.

◆ $passwordConfirmLabel

AutoForm::$passwordConfirmLabel = "Confirm"

Text for Password Confirm label.

Definition at line 88 of file auto_form.inc.

◆ $passwordEncryptor

AutoForm::$passwordEncryptor = ""

Password Encryption method name.

Definition at line 57 of file auto_form.inc.

◆ $passwordEnterLabel

AutoForm::$passwordEnterLabel = "Enter"

Text for Password Enter label.

Definition at line 87 of file auto_form.inc.

◆ $readonly

AutoForm::$readonly = array()

The read-only fields collection.

Definition at line 75 of file auto_form.inc.

◆ $readOnlyForm

AutoForm::$readOnlyForm

Specifies whether the entire form is read-only.

Definition at line 120 of file auto_form.inc.

◆ $renderers

AutoForm::$renderers = array()

The field renderers collection.

Definition at line 70 of file auto_form.inc.

◆ $required

AutoForm::$required = array()

List of required fields.

Definition at line 106 of file auto_form.inc.

◆ $requiredFieldsText

AutoForm::$requiredFieldsText = "* indicates required field"

Text prompt to display when a form contains required fields.

Definition at line 107 of file auto_form.inc.

◆ $showAnnotations

AutoForm::$showAnnotations = true

Set to false to hide field annotations.

Definition at line 123 of file auto_form.inc.

◆ $style

AutoForm::$style = ""

Definition at line 54 of file auto_form.inc.

◆ $submitLabel

AutoForm::$submitLabel = ""

Text to display on the form's submit button. If not specified defaut text will be generated based on the target DataItem.

Definition at line 62 of file auto_form.inc.

◆ $subordinate

AutoForm::$subordinate

Specifies whether this form is a subordinate member of a composite form.

Definition at line 121 of file auto_form.inc.

◆ $useLinkSubmit

AutoForm::$useLinkSubmit = false

Flag to indicate whether the submit button for the form should be rendered as a link (not common).

Definition at line 81 of file auto_form.inc.

◆ $validator

AutoForm::$validator

The ValidationEngine for this form.

Definition at line 80 of file auto_form.inc.

◆ $valueCSS

AutoForm::$valueCSS = ""

CSS Class to use for field/value cells.

Definition at line 49 of file auto_form.inc.


The documentation for this class was generated from the following file: