Framework  3.9
FilterForm Class Reference

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...

+ Inheritance diagram for FilterForm:
+ Collaboration diagram for FilterForm:

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...
 

Detailed Description

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.

Author
Janice Gallant for Sonjara, Inc.

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.

Member Function Documentation

◆ drawForm()

FilterForm::drawForm ( )

Write out the HTML for the search form.

See also
framework/AutoFormdrawForm()

Reimplemented from SearchForm.

Definition at line 209 of file filter_form.inc.

210  {
211  $obj =& $this->data;
212  $pk = $obj->getPrimaryKey();
213  if ($this->preserveQueryString)
214  {
215  $obj->fromREQUEST();
216  }
217 
218 // echo "<p>Empty: {$this->params->empty}</p>";
219 // echo "<p>Default State: {$this->params->isDefaultState}</p>";
220 // echo "<p>".$this->sessionKey()."</p>";
221 // echo "<pre>".$_SESSION[$this->sessionKey()]."</pre>";
222  echo "<form id='{$this->id}' method='{$this->method}' action='{$this->action}' enctype='multipart/form-data'";
223  if (!$this->ajaxSubmitHandler)
224  {
225  echo " onsubmit='return onSubmit{$this->id}(this);'";
226  }
227 
228  if ($this->navigationMode == 'panel')
229  {
230  echo " data-mode='ajax'";
231  }
232  echo ">\n";
233 
234  echo "<div";
235  if ($this->formCSS) echo " class='{$this->formCSS}'";
236  if ($this->style) echo " style='{$this->style}'";
237  echo ">\n";
238 
239  foreach(array_keys($this->hidden) as $hidden)
240  {
241  if ($obj->filter && $obj->filter->isExcluded($hidden)) continue;
242 
243  echo "<input id='{$this->id}_{$hidden}' type='hidden' name='$hidden' value='".htmlSafe($obj->get($hidden))."'/>\n";
244  }
245 
246  if ($this->preserveQueryString)
247  {
248  foreach($_GET as $key => $value)
249  {
250  if ($key == "identifier" || $key == "section" || $key == "submit" || array_key_exists($this->hidden, $key) || $obj->hasField($key)) continue;
251  echo "<input id='{$this->id}_{$key}' type='hidden' name='$key' value='".htmlSafe($value)."'/>\n";
252  }
253  }
254 
255  $this->layout->startUngrouped();
256 
257  if ($this->formLabel) echo "<div class='filter_form_label'><label>{$this->formLabel}</label></div>";
258  $this->renderSearchFields();
259  if ($this->showSubmitButton)
260  {
261  echo "<input type='submit' class='button' value='{$this->submitButtonLabel}'/>";
262  }
263  else
264  {
265  // Hidden submit button allow filter to be run by hitting enter
266  echo "<input type='submit' style='display: none'/>";
267  }
268 
269  $this->layout->endUngrouped();
270 
271  $this->layout->finalizeLayout();
272  echo "</div>\n";
273  echo "</form>\n";
274  echo "<div style=\"clear: both\">\n</div>\n";
275  }
$hidden
The hidden fields collection.
Definition: auto_form.inc:72
renderSearchFields()

◆ FilterForm()

FilterForm::FilterForm (   $target,
  $method = "GET",
  $action = "",
  $id = "" 
)

Definition at line 130 of file filter_form.inc.

131  {
132  parent::SearchForm($target, $method, $action, $id);
133  $this->layout = new FilterFormLayout($this);
134  $this->formCSS = "filter";
135  $this->setFilterParameters();
136  }
$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
$method
HTTP method that will be used to submit the form.
Definition: auto_form.inc:67
setFilterParameters()
Default for all parameters included in filter is equal Additional search parameters can be added by c...
Layout for list filtering using filter_form.inc.

◆ getConstraint()

FilterForm::getConstraint (   $first = true,
  $firstText = "WHERE" 
)

Definition at line 398 of file filter_form.inc.

399  {
400  if ($this->rememberFilter)
401  {
402  if ($this->params->isDefaultState)
403  {
404  $this->loadFilterFromSession();
405  }
406  else
407  {
408  $this->saveFilterToSession();
409  }
410  }
411 
412  return $this->params->generateConstraint($first, $firstText);
413  }

◆ getLink()

FilterForm::getLink (   $url)

Definition at line 138 of file filter_form.inc.

139  {
140  return str_replace("{url}", $url, $this->navigationFunction);
141  }

◆ getOnSubmitFunction()

FilterForm::getOnSubmitFunction ( )

Definition at line 158 of file filter_form.inc.

159  {
160  return "onSubmit{$this->id}";
161  }

◆ renderSearchFields()

FilterForm::renderSearchFields ( )

Reimplemented from SearchForm.

Definition at line 281 of file filter_form.inc.

282  {
283  $obj =& $this->data;
284  $filter = $obj->getFilter();
285 
286  if (count($this->groups) > 0)
287  {
288  $this->layout->endUngrouped();
289 
290  foreach($this->groups as $legend => $fields)
291  {
292  $collapsible = array_key_exists($legend, $this->collapsibleGroups);
293  if ($collapsible)
294  {
295  $cf = $this->collapsibleGroups[$legend];
296  $collapsed = !$this->data->$cf;
297  }
298 
299  $this->layout->startGroup($legend, $collapsible, $collapsed);
300 
301  foreach($fields as $field)
302  {
303  if ($field != $pk && !array_key_exists($field, $this->hidden) && !array_key_exists($field, $this->renderedFields) && !($filter && $filter->isExcluded($field)))
304  {
305  $this->renderOneSearchField($field);
306  }
307  }
308 
309  $this->layout->endGroup();
310  }
311 
312  $this->layout->startUngrouped();
313 
314  }
315 
316  foreach(array_keys($this->fields) as $field)
317  {
318  if ($field != $pk && !array_key_exists($field, $this->hidden) && !array_key_exists($field, $this->renderedFields) && !($filter && $filter->isExcluded($field)))
319  {
320  $renderer = $this->getRenderer($field);
321  if(get_class($renderer) == DateRangeFilterRenderer)
322  {
323  $dateRangeField = $field;
324  continue;
325  }
326  $this->renderOneSearchField($field);
327  }
328  }
329 
330  foreach($this->additional as $r)
331  {
332  $renderer = $r['renderer'];
333  $field = $r['field'];
334  if(!$field)
335  $field = $renderer->field;
336  if (!array_key_exists($field, $this->renderedFields))
337  {
338  if(get_class($renderer) == DateRangeFilterRenderer)
339  {
340  $dateRangeField = $field;
341  continue;
342  }
343  $this->renderOneSearchField($field);
344  }
345  }
346 
347  if($dateRangeField)
348  {
349  $this->renderOneSearchField($dateRangeField);
350  }
351  }
$fields
Local field cache.
Definition: auto_form.inc:111
getRenderer($field)
Retrieves the FieldRenderer object for the specified field.
Definition: auto_form.inc:512
renderOneSearchField($field)

◆ setFilterParameters()

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.

374  {
375  $obj = $this->data;
376 
377  // JDG 9/2011 handle CompositeDataItems
378  $fields = $obj->getFields();
379  $this->params = new SearchParameters($obj);
380 
381  foreach(array_keys($fields) as $field)
382  {
383  if (!array_key_exists($field, $this->hidden) &&
384  !($obj->filter && $obj->filter->isExcluded($field))
385  )
386  {
387  $value = $obj->get($field);
388  // AJG - Removing this logic as it is incorrectly re-encoding parameters leading to bad side-effects
389  // Application code that breaks as a result of this should be fixed in the application
390  //if($value && !is_int($value))
391  // $value = urlencode($value);
392  if($value)
393  $this->params->setParam($field, "equal", $value);
394  }
395  }
396  }
The SearchParameters class interprets the set of input parameters for a search and generates the corr...

◆ setHandler()

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.

361  {
362  $this->params->paramHandlers[$field] = $handler;
363  }

◆ setNavigationMode()

FilterForm::setNavigationMode (   $mode)

Sets the navigation mode for the FilterForm.

Parameters
string$modeUse 'form' for page reloads, or 'panel' for AJAX panel reloads

Definition at line 147 of file filter_form.inc.

148  {
149  $this->navigationMode = $mode;
150  if ($mode == "panel")
151  {
152  $this->navigationFunction = "loadPanel(form, '{url}');";
153  $this->onSubmitHandler = "{$this->id}_loadPanel";
154  $this->action = Fakoli::scriptName();
155  }
156  }

◆ setParam()

FilterForm::setParam (   $field,
  $mode,
  $value 
)

Definition at line 415 of file filter_form.inc.

416  {
417  $this->params->setParam($field, $mode, $value);
418  }

◆ writeScript()

FilterForm::writeScript ( )

Generate any javascript required by the search form.

See also
framework/AutoFormwriteScript()

Reimplemented from SearchForm.

Definition at line 163 of file filter_form.inc.

164  {
165  if ($this->navigationMode == "panel")
166  {
167  $script = <<<ENDSCRIPT
168 <script type="text/javascript">
169 function {$this->id}_loadPanel(form)
170 {
171  var form = new Element(form);
172  var url = form.action + "?" + form.toQueryString();
173  form.loadPanel(url);
174  return false;
175 }
176 </script>
177 ENDSCRIPT;
178  }
179  return $script . parent::writeScript();
180  }

Member Data Documentation

◆ $formLabel

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.

◆ $navigationFunction

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.

◆ $navigationMode

FilterForm::$navigationMode = "form"

Mode used for navigating after filter changed - either "form" or "panel".

Definition at line 124 of file filter_form.inc.

◆ $preserveQueryString

FilterForm::$preserveQueryString = false

Definition at line 122 of file filter_form.inc.

◆ $rememberFilter

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.

◆ $showSubmitButton

FilterForm::$showSubmitButton = false

Whether to show the submit button on a filter form.

Definition at line 125 of file filter_form.inc.

◆ $submitButtonLabel

FilterForm::$submitButtonLabel = "Filter Results"

Text to show on the filter form submit button, if present.

Definition at line 126 of file filter_form.inc.


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