Framework
3.9
|
Filter form adds a select field renderer to a page that allows the user to select one item from the filter and the page reloads, querying the list of items using the filter selection. More...
Public Member Functions | |
FilterForm ($target, $method="GET", $action="", $id="") | |
getLink ($url) | |
setNavigationMode ($mode) | |
Sets the navigation mode for the FilterForm. More... | |
getOnSubmitFunction () | |
writeScript () | |
Generate any javascript required by the search form. More... | |
drawForm () | |
Write out the HTML for the search form. More... | |
renderSearchFields () | |
setHandler ($field, $handler) | |
Override an existing SearchParameter constraint clause handler or add one. More... | |
setFilterParameters () | |
Default for all parameters included in filter is equal Additional search parameters can be added by calling script with the syntax: $filterForm->params->setParam("round_id", "member", implode(",", array_keys($rounds))); Do not include these additional parameters in the object filter. More... | |
getConstraint ($first=true, $firstText="WHERE") | |
setParam ($field, $mode, $value) | |
Public Member Functions inherited from SearchForm | |
SearchForm ($target, $method="POST", $action="", $id="") | |
Create a new Search Form. More... | |
setMatchingMode ($mode) | |
Sets the matching mode for the specified fields. More... | |
getMatchingMode ($field) | |
Retrieve the matching mode that was set for the specified field. More... | |
populateFromGET () | |
Populate the search parameters from an HTTP GET request. More... | |
populateFromPOST () | |
Populate the search parameters from an HTTP POST request. More... | |
populateFromREQUEST () | |
addDefaultValidators () | |
Creates default validators for fields in the form. More... | |
setSearchValidator ($renderer, $field, $mode) | |
After AutoForm configures the validators, modify the field name to include the mode with which the tag will drawn in the form. More... | |
renderOneSearchField ($field) | |
renderAdditionalFields ($obj) | |
drawReadOnly () | |
Draws the form in read-only mode. More... | |
Public Member Functions inherited from AutoForm | |
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... | |
getValidationEngine () | |
Retrieve the validation engine for this AutoForm. More... | |
makeSubordinate () | |
Set this AutoForm to be a subordinate form within a CompositeAutoForm. More... | |
configureValidators () | |
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... | |
drawSubmitButtons ($obj, $pk, $submitLabel) | |
renderAllFields ($obj) | |
renderFields ($obj) | |
renderOneField ($field, $renderScript=false) | |
drawButtons () | |
Draws any additional buttons specified in the calling script. 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 () | |
Public Attributes | |
$preserveQueryString = false | |
$navigationFunction = "go('{url}')" | |
Format specifier for the default javascript navigation function to be used by fields in the FilterForm. More... | |
$navigationMode = "form" | |
Mode used for navigating after filter changed - either "form" or "panel". More... | |
$showSubmitButton = false | |
Whether to show the submit button on a filter form. More... | |
$submitButtonLabel = "Filter Results" | |
Text to show on the filter form submit button, if present. More... | |
$formLabel = null | |
Text to display before the start of the form (such as 'Filter By') More... | |
$rememberFilter = false | |
Set to true to remember the chosen filter parameters and re-apply them if none are set (when returning to a page) More... | |
Public Attributes inherited from SearchForm | |
$modifiers | |
$params | |
$hasSearchCriteria = false | |
$emptyMessage = "No search criteria was provided." | |
$preserveQueryString = false | |
$searchModeTypes | |
Public Attributes inherited from AutoForm | |
$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... | |
Additional Inherited Members | |
Static Public Member Functions inherited from AutoForm | |
static | registerFieldRendererClass ($type, $rendererClass) |
Registers a custom type-to-renderer mapping. More... | |
Static Public Attributes inherited from AutoForm | |
static | $fieldRendererMap |
Provides the mapping from Type identifier to FieldRenderer. More... | |
Filter form adds a select field renderer to a page that allows the user to select one item from the filter and the page reloads, querying the list of items using the filter selection.
The concept is that a list page of objects of class myItem, can be filtered by creating an empty instance of class myItem, assigning the "GET" filter values to fields in that instance. Only fields in myItem that are useful for the filter would be included in its object filter.
4/2011
Example of incorporating this feature into a form that lists budget table data where budget obj has field "year" and we show a year drop down.
Fakoli::usingFeature("filter_form");
$year = checkNumeric($_GET["year"]);
if(!$year) // get your default year $year = FiscalYear::currentYear()->year;
$budget = new Budget(); $budget->year = $year; $budget->filter = new InclusionFilter("year"); $filterForm = new FilterForm($budget);
$yearSelect = new FilterFieldRenderer($filterForm, "year", "Year", Budget::getYearOptions());
$yearSelect->all = false; // we don't want to show "All" option in the filter
$constraint = $filterForm->getConstraint();
$filterForm->drawForm();
Example of filtering application objects:
$application = new Application(); $application->status = checkNumeric($_GET["status"]); $application->round_id = $_GET["round_id"]; $application->country_id = $_GET["country_id"]; $application->filter = new InclusionFilter("status", "country_id", "round_id"); $filterForm = new FilterForm($application); $statusSelect = new FilterFieldRenderer($filterForm, "status", "Status", $application->statusTypes); $roundSelect = new FilterFieldRenderer($filterForm, "round_id", "Round", FundingRound::getRoundList()); $countrySelect = new FilterFieldRenderer($filterForm, "country_id", "Country", Country::getList("WHERE country_id in (SELECT country_id FROM application)"));
$applications = query(Application, $filterForm->getConstraint()." ORDER BY round_key DESC");
$filterForm->drawForm();
Example when using CompositeDataItems: Must use methods get and set on the CompositeDataItem
$filterForm->data->set("event_type", $_GET["event_type"]);
$te = new CompositeTrainingEvent(); $te->filter = new InclusionFilter("event_type"); $te->set("event_type", $_GET["event_type"]); $filterForm = new FilterForm($te); $typeSelect = new FilterFieldRenderer($filterForm, "event_type", "Event Type", array(TrainingEvent::formatEventTypes()));
$constraint = $filterForm->getConstraint();
Use constraint to query on your target object's table, e.g., "Events"
$filterForm->drawForm();
Definition at line 120 of file filter_form.inc.
FilterForm::drawForm | ( | ) |
Write out the HTML for the search form.
Reimplemented from SearchForm.
Definition at line 209 of file filter_form.inc.
FilterForm::FilterForm | ( | $target, | |
$method = "GET" , |
|||
$action = "" , |
|||
$id = "" |
|||
) |
Definition at line 130 of file filter_form.inc.
FilterForm::getConstraint | ( | $first = true , |
|
$firstText = "WHERE" |
|||
) |
Definition at line 398 of file filter_form.inc.
FilterForm::getLink | ( | $url | ) |
Definition at line 138 of file filter_form.inc.
FilterForm::getOnSubmitFunction | ( | ) |
Definition at line 158 of file filter_form.inc.
FilterForm::renderSearchFields | ( | ) |
Reimplemented from SearchForm.
Definition at line 281 of file filter_form.inc.
FilterForm::setFilterParameters | ( | ) |
Default for all parameters included in filter is equal Additional search parameters can be added by calling script with the syntax: $filterForm->params->setParam("round_id", "member", implode(",", array_keys($rounds))); Do not include these additional parameters in the object filter.
Definition at line 373 of file filter_form.inc.
FilterForm::setHandler | ( | $field, | |
$handler | |||
) |
Override an existing SearchParameter constraint clause handler or add one.
@handler - callback function that creates the constraint clause for the given field
Reimplemented from SearchForm.
Definition at line 360 of file filter_form.inc.
FilterForm::setNavigationMode | ( | $mode | ) |
Sets the navigation mode for the FilterForm.
string | $mode | Use 'form' for page reloads, or 'panel' for AJAX panel reloads |
Definition at line 147 of file filter_form.inc.
FilterForm::setParam | ( | $field, | |
$mode, | |||
$value | |||
) |
Definition at line 415 of file filter_form.inc.
FilterForm::writeScript | ( | ) |
Generate any javascript required by the search form.
Reimplemented from SearchForm.
Definition at line 163 of file filter_form.inc.
FilterForm::$formLabel = null |
Text to display before the start of the form (such as 'Filter By')
Definition at line 127 of file filter_form.inc.
FilterForm::$navigationFunction = "go('{url}')" |
Format specifier for the default javascript navigation function to be used by fields in the FilterForm.
Definition at line 123 of file filter_form.inc.
FilterForm::$navigationMode = "form" |
Mode used for navigating after filter changed - either "form" or "panel".
Definition at line 124 of file filter_form.inc.
FilterForm::$preserveQueryString = false |
Definition at line 122 of file filter_form.inc.
FilterForm::$rememberFilter = false |
Set to true to remember the chosen filter parameters and re-apply them if none are set (when returning to a page)
Definition at line 128 of file filter_form.inc.
FilterForm::$showSubmitButton = false |
Whether to show the submit button on a filter form.
Definition at line 125 of file filter_form.inc.
FilterForm::$submitButtonLabel = "Filter Results" |
Text to show on the filter form submit button, if present.
Definition at line 126 of file filter_form.inc.