FormField
public class FormField
Field Summary | |
---|---|
mixed | True if values of not editable or not enabled fields should be propagated using a hidden field. |
mixed | True if this field should be considered data and the field value should be read from a database and written to a database. |
mixed | If the enterTabs is true, the HTML included in the input tag to disable when the user presses enter while editing a field. |
mixed | True if multiple values should be separated by new lines. |
mixed | True if this field is editible. |
mixed | True if the field is enabled. |
mixed | The string displayed directly after the field label. |
mixed | If the enterTabs is true, the HTML included in the input tag to process a tab. |
mixed | True if we should force a tab when enter is pressed when editing this field. |
mixed | The error string associated with this field upon a failed validation. |
mixed | Any extra HTML/JavaScript code that should be inserted into the input tag. |
mixed | True if the field should be displayed below the label instead of inline with the label. |
mixed | An error string set by this field that is not particular to this field and will be propagated up to FfForm. |
mixed | The HTML help string that appears to the right of a field. |
mixed | True if this field is a hidden field. |
mixed | True if FORMfields should try to automatically HTMLify the HTML display value of this field. |
mixed | The value of the id attribute printed in this field's input tag. |
mixed | True if this field should be considered data and the field value should be read from a database and written to a database. |
mixed | This form field's label. |
mixed | The value of the for attribute in the input tag. |
mixed | True if this is a multiple value field. |
mixed | The name of the form field. |
mixed | Whether the field must be filled in and whether it looks like it must be filled in. |
mixed | $subFieldDisplayValueSeparator A string separator used to separate the display values of the sub fields. |
mixed | A string separator used to separate the sub fields when they are being edited. |
mixed | A string separator used to separate the values of the sub fields. |
mixed | An array of sub fields, if any, for this field. |
mixed | True if an empty sub field constitutes an invalid value. |
mixed | True if whitespace should automatically be trimmed from user entered values. |
mixed | Callback classes that are used to implement form validation. |
mixed | The value of this form field. |
mixed | True if FORMfields should not apply htmlspecialchars() or try to automatically HTMLify the HTML display value of this field. |
Constructor Summary | |
---|---|
FormField(string name, string label, int required) FormField constructor. |
|
__construct(string name, string label, int required) FormField constructor. |
Method Summary | |
---|---|
void | addFieldValidator(mixed fieldValidator) Add a field validator, a callback class that is used to implement form validation. |
void | addSubField(FormField field) Append a sub field to the end of the subFields array. |
boolean | Returns true if this field's value is blank and if it is, also sets the field error. |
void | Sets this field's value to null. |
void | disable() Disables the field. |
returns | formatRequestParameter(mixed value) A static method that returns a formatted $_REQUEST value. |
string | formatText(mixed text) A static method that returns text wrapped in FORMfields span tags. |
boolean | Returns true if a submit button from this field was clicked. |
boolean | getData() Returns whether this field should be considered data and if this field's value should be read from a database and written to a database. |
string | Returns the database value of this field. |
string | Returns JavaScript code to disable the input field portion of this field during run-time. |
string | Returns JavaScript code to disable this field during run-time. |
string | Returns JavaScript code to disable the label portion of this field during run-time. |
string | getDisplayFieldTag(boolean displayHelp) Returns the HTML used to display this field's value and not within an input field. |
string | Returns the HTML value of this field. |
string | getDisplayLabelTag(string cssPostfix, boolean wrap) Returns the HTML used to display this field's display label. |
string | Returns the display value of this field. |
boolean | Returns whether this field is editable. |
string | Returns the HTML used to display the input portion of this field. |
string | getEditableLabelTag(string cssPostfix, boolean wrap) Returns the HTML used to display this field's editiable label. |
boolean | Returns whether the field is enabled. |
string | getError() Returns the error string associated with this field upong a failed validation. |
string | Returns any extra HTML/JavaScript code that should be inserted into the input tag. |
string | Returns the HTML to display this field. |
string | Returns the the error string set by this field that is not particular to this field and will be propagated up to the FfForm. |
string | getHelp() Returns the HTML help string that appears to the right of a field. |
string | Returns the HTML used to display this field's help text. |
boolean | Returns whether this field is a hidden field. |
string | Returns the HTML that describes this field as a hidden field. |
string | getId() Returns the value of the id attribute printed in this field's input tag. |
boolean | Returns whether this field should be considered data and if this field's value should be read from a database and written to a database. |
boolean | Returns whether this field is a hidden field. |
string | getLabel() Returns this form field's label. |
string | getLabelHtml(boolean wrap) Returns the HTML used to display the label. |
string | getLabelTag(string cssPostfix, boolean wrap) Returns the HTML used to display this field's label based on the field's editable state. |
string | getName() Returns the name of the form field. |
mixed | getOrNull(string index, array anArray) A static method that returns the value in the array at the specified index or null, if the value doesn't exist. |
void | Retrieves the posted field value. |
string | Returns the raw database value of this field. |
int | Returns whether the field must be filled in and whether it looks like it must be filled in. |
mixed | getValue() Returns the value of this form field. |
boolean | isBlank(string value) A static method that returns true if value is blank such as the value of a field when the user hasn't filled in that field. |
boolean | isEmpty() Returns true if the field value is blank such as when the user hasn't filled in the value. |
boolean | isValid() Checks for field errors detected by this field, including a check for blank. |
void | setAutoPropagate(boolean autoPropagate) Sets whether values of not editable or not enabled fields should be propagated using a hidden field. |
void | setData(mixed data, boolean true) Sets whether this field should be considered data and if this field's value should be read from a database and written to a database. |
void | setDbValue(string value) Sets the database value of this field. |
void | setDisplayValuesOnNewLine(boolean displayValuesOnNewLine) Sets whether multiple values should be separated by new lines. |
void | setEditable(boolean editable) Sets whether this field is editable. |
void | setEnabled(boolean enabled) Sets whether the field is enabled. |
void | setEndingString(string endingString) Sets the string displayed directly after the field label. |
void | setError(string error) Sets the error string associated with this field upon a failed validation. |
void | setExtraHtml(string extraHtml) Sets any extra HTML/JavaScript code that should be inserted into the input tag. |
void | setFieldBelowLabel(boolean fieldBelowLabel) Sets where the field should be displayed below the label instead of inline with the label. |
void | setFormError(string error) Sets the the error string set by this field that is not particular to this field and will be propagated up to the FfForm. |
void | setHelp(string help) Sets the HTML help string that appears to the right of a field. |
void | setHidden(boolean hidden) Sets whether this field is a hidden field. |
void | setHtmlify(boolean htmlify) Sets whether FORMfields should try to automatically HTMLify the HTML display value of this field. |
void | setId(string id) Sets the value of the id attribute printed in this field's input tag. |
void | setIsData(mixed data, boolean true) Sets whether this field should be considered data and if this field's value should be read from a database and written to a database. |
void | setIsHidden(boolean hidden) Sets whether this field is a hidden field. |
void | setLabel(string label) Sets the label of this form field. |
void | setName(string name) Sets the name of the form field. |
void | setRequired(int required) Sets whether the field must be filled in and whether it looks like it must be filled in. |
void | setTrimWhitespace(boolean trimWhitespace) Sets whether whitespace should automatically be trimmed from user entered values. |
void | setValue(mixed value) Sets the value of this form field. |
void | setValueIsHtml(boolean valueIsHtml) Sets whether if FORMfields should not apply htmlspecialchars() or try to automatically HTMLify the HTML display value of this field. |
boolean | validate() Performs field value validation using any form validators and checks for errors. |
public mixed $autoPropagate = true
True if values of not editable or not enabled fields should be propagated using a hidden field. This feature provides great convienence, but can be insecure as the user can insert values into these hidden fields. This however, is not usually a problem as typically users only have access to modify their own data and have no interest in corrupting their own data.
public mixed $data = true
True if this field should be considered data and the field value should be read from a database and written to a database.
public mixed $disableEnterHandler = " onkeypress=\"return disableEnter(event);\" "
If the enterTabs is true, the HTML included in the input tag to disable when the user presses enter while editing a field.
public mixed $displayValuesOnNewLine = true
True if multiple values should be separated by new lines. This value is ignored if this field is a single value field.
public mixed $editable = true
True if this field is editible. A field that is not editable shows the field value as a string and not as a typical input field.
public mixed $enabled = true
True if the field is enabled. A disabled field shows as a typcial input field, but is grayed out and cannot be modified.
public mixed $endingString = FORM_FIELD_DEFAULT_ENDING_STRING
The string displayed directly after the field label. This value is defaulted to ":".
public mixed $enterTabHandler = " onkeypress=\"return enterTabHandler(this, event);\" "
If the enterTabs is true, the HTML included in the input tag to process a tab.
public mixed $enterTabs = false
True if we should force a tab when enter is pressed when editing this field. Unfortunately, the way web browsers respond when "enter" is pressed while in a text field is not standard. Therefore, it is sometimes diserable standardize and force a tab when "enter" is pressed.
public mixed $error = null
The error string associated with this field upon a failed validation.
public mixed $extraHtml = null
Any extra HTML/JavaScript code that should be inserted into the input tag. For example, "onclick="alert('clicked')"".
public mixed $fieldBelowLabel = false
True if the field should be displayed below the label instead of inline with the label.
public mixed $formError = null
An error string set by this field that is not particular to this field and will be propagated up to FfForm.
public mixed $help = null
The HTML help string that appears to the right of a field. See HTML Special Characters
public mixed $hidden = false
True if this field is a hidden field.
public mixed $htmlify = true
True if FORMfields should try to automatically HTMLify the HTML display value of this field. In doing so, URL's and email addresses are converted to hyperlinks.
public mixed $id = null
The value of the id attribute printed in this field's input tag. The id value is defaulted to the field's name. Note: The id can be used to reference this field in JavaScript.
public mixed $isData = true
True if this field should be considered data and the field value should be read from a database and written to a database.
public mixed $label = null
This form field's label. The label is the printable text that is typically displayed on the left side of the field.
public mixed $labelForId = null
The value of the for attribute in the input tag. This value associates a label with a field so that in say the case of a radio button, the user can click the radio button label and cause a click on the appropriate radio button box.
public mixed $multiValues = false
True if this is a multiple value field. Most of the time this value remains a constant per field type.
public mixed $name = null
The name of the form field. This value must not be a SQL reserved word and should follow all the standard variable naming conventions in PHP.
public mixed $required = FORM_FIELD_REQUIRED
Whether the field must be filled in and whether it looks like it must be filled in.
public FormField(string name, string label, int required)
FormField constructor.
public void addFieldValidator(mixed fieldValidator)
Add a field validator, a callback class that is used to implement form validation.
public void addSubField(FormField field)
Append a sub field to the end of the subFields array.
public boolean checkForBlank()
Returns true if this field's value is blank and if it is, also sets the field error.
public void clearValue()
Sets this field's value to null. This includes setting the values of any sub fields.
public void disable()
Disables the field. A disabled field shows as a typcial input field, but is grayed out and cannot be modified.
public returns formatRequestParameter(mixed value)
A static method that returns a formatted $_REQUEST value. This is needed as values are encoded during form submission.
public string formatText(mixed text)
A static method that returns text wrapped in FORMfields span tags. This method is used to format text used when displaying input fields.
public boolean getButtonClicked()
Returns true if a submit button from this field was clicked. This method is used to control how a form is processed. Note: submit button clicks like refreshes from a SetSelectorField are considered button clicks by this method.
public boolean getData()
Returns whether this field should be considered data and if this field's value should be read from a database and written to a database.
public string getDbValue()
Returns the database value of this field. A database value can be different than the field's actual value. For example a phone number may have the value "973-746-3233" but its database value would be "'9737463233'". Note: wrapping single quotes are automatically added to a database value for easy use in an SQL query. Furthermore, if the field value is null then the database value will be "null" and not "'null'".
public string getDisableFieldJs()
Returns JavaScript code to disable the input field portion of this field during run-time.
public string getDisableJs()
Returns JavaScript code to disable this field during run-time.
public string getDisableLabelJs()
Returns JavaScript code to disable the label portion of this field during run-time.
public string getDisplayFieldTag(boolean displayHelp)
Returns the HTML used to display this field's value and not within an input field.
public string getDisplayHtmlValue()
Returns the HTML value of this field. For example, the value could be "www.formfields.com" and the HTML display value could be "My Website".
public string getDisplayLabelTag(string cssPostfix, boolean wrap)
Returns the HTML used to display this field's display label.
public string getDisplayValue()
Returns the display value of this field. For example, the field may have a value of "2127348943" and its display value could be "212-734-8943".
public boolean getEditable()
Returns whether this field is editable. A field that is not editable shows the field value as a string and not as a typical input field.
public string getEditableFieldTag()
Returns the HTML used to display the input portion of this field.
public string getEditableLabelTag(string cssPostfix, boolean wrap)
Returns the HTML used to display this field's editiable label.
public boolean getEnabled()
Returns whether the field is enabled. A disabled field shows as a typcial input field, but is grayed out and cannot be modified.
public string getError()
Returns the error string associated with this field upong a failed validation.
public string getExtraHtml()
Returns any extra HTML/JavaScript code that should be inserted into the input tag. For example, "onclick="alert('clicked')"".
public string getFieldTag()
Returns the HTML to display this field.
public string getFormError()
Returns the the error string set by this field that is not particular to this field and will be propagated up to the FfForm.
public string getHelp()
Returns the HTML help string that appears to the right of a field. See HTML Special Characters
public string getHelpTag()
Returns the HTML used to display this field's help text.
public boolean getHidden()
Returns whether this field is a hidden field.
public string getHiddenFieldTag()
Returns the HTML that describes this field as a hidden field.
public string getId()
Returns the value of the id attribute printed in this field's input tag. The id value is defaulted to the field's name. Note: The id can be used to reference this field in JavaScript.
public boolean getIsData()
Returns whether this field should be considered data and if this field's value should be read from a database and written to a database.
public boolean getIsHidden()
Returns whether this field is a hidden field.
public string getLabel()
Returns this form field's label. The label is the printable text that is typically displayed on the left side of the field.
public string getLabelHtml(boolean wrap)
Returns the HTML used to display the label. Note: we wrap the label based on character length to standardize the label width as each browser implements the max length of a CSS element in different ways.
public string getLabelTag(string cssPostfix, boolean wrap)
Returns the HTML used to display this field's label based on the field's editable state.
public string getName()
Returns the name of the form field. This value must not be a SQL reserved word and should follow all the standard variable naming conventions in PHP.
public mixed getOrNull(string index, array anArray)
A static method that returns the value in the array at the specified index or null, if the value doesn't exist.
public void getParameter()
Retrieves the posted field value. In other words, sets this field value using the appropriate value(s) in $_REQUEST.
public string getRawDbValue()
Returns the raw database value of this field. A database value can be different than the field's actual value. For example a phone number may have the value "973-746-3233" but its raw database value would be "9737463233".
public int getRequired()
Returns whether the field must be filled in and whether it looks like it must be filled in.
public mixed getValue()
Returns the value of this form field.
public boolean isBlank(string value)
A static method that returns true if value is blank such as the value of a field when the user hasn't filled in that field.
public boolean isEmpty()
Returns true if the field value is blank such as when the user hasn't filled in the value.
public boolean isValid()
Checks for field errors detected by this field, including a check for blank. If an error is detected, the setError() method is called to set the appropriate error message.
public void setAutoPropagate(boolean autoPropagate)
Sets whether values of not editable or not enabled fields should be propagated using a hidden field. This feature provides great convienence, but can be insecure as the user can insert values into these hidden fields. This however, is not usually a problem as typically users only have access to modify their own data and have no interest in corrupting their own data.
public void setData(mixed data, boolean true)
Sets whether this field should be considered data and if this field's value should be read from a database and written to a database.
public void setDbValue(string value)
Sets the database value of this field. A database value can be different than the field's actual value. For example a phone number may have the value "973-746-3233" but its database value would be "9737463233"
public void setDisplayValuesOnNewLine(boolean displayValuesOnNewLine)
Sets whether multiple values should be separated by new lines. This value is ignored if this field is a single value field.
public void setEditable(boolean editable)
Sets whether this field is editable. A field that is not editable shows the field value as a string and not as a typical input field.
public void setEnabled(boolean enabled)
Sets whether the field is enabled. A disabled field shows as a typcial input field, but is grayed out and cannot be modified.
public void setEndingString(string endingString)
Sets the string displayed directly after the field label. This value is defaulted to ":".
public void setError(string error)
Sets the error string associated with this field upon a failed validation.
public void setExtraHtml(string extraHtml)
Sets any extra HTML/JavaScript code that should be inserted into the input tag. For example, "onclick="alert('clicked')"".
public void setFieldBelowLabel(boolean fieldBelowLabel)
Sets where the field should be displayed below the label instead of inline with the label.
public void setFormError(string error)
Sets the the error string set by this field that is not particular to this field and will be propagated up to the FfForm.
public void setHelp(string help)
Sets the HTML help string that appears to the right of a field. See HTML Special Characters
public void setHidden(boolean hidden)
Sets whether this field is a hidden field.
public void setHtmlify(boolean htmlify)
Sets whether FORMfields should try to automatically HTMLify the HTML display value of this field. In doing so, URL's and email addresses are converted to hyperlinks. This value is true by default.
public void setId(string id)
Sets the value of the id attribute printed in this field's input tag. The id value is defaulted to the field's name. Note: The id can be used to reference this field in JavaScript.
public void setIsData(mixed data, boolean true)
Sets whether this field should be considered data and if this field's value should be read from a database and written to a database.
public void setIsHidden(boolean hidden)
Sets whether this field is a hidden field.
public void setLabel(string label)
Sets the label of this form field. The label is the printable text that is typically displayed on the left side of the field.
public void setName(string name)
Sets the name of the form field. This value must not be a SQL reserved word and should follow all the standard variable naming conventions in PHP.
public void setRequired(int required)
Sets whether the field must be filled in and whether it looks like it must be filled in.
FormField is the base class of a form field.