CWIS Developer Documentation
OptionFormField.php
Go to the documentation of this file.
1 <?PHP
2 
3 #
4 # FILE: OptionFormField.php
5 #
6 # Part of the Collection Workflow Integration System (CWIS)
7 # Copyright 2013 Edward Almasy and Internet Scout Research Group
8 # http://scout.wisc.edu/cwis/
9 #
10 
16 class OptionFormField extends FormField {
17 
18  # ---- PUBLIC INTERFACE --------------------------------------------------
19 
22 
33  function OptionFormField(
34  $Name, $IsRequired, $Label, $Length, $Options,
35  $ValidFunc = NULL, $ValidMsgs = NULL)
36  {
37  $this->MyLength = $Length;
38  $this->MyOptions = $Options;
39 
40  $this->FormField($Name, $IsRequired, $Label, $ValidFunc, $ValidMsgs);
41  }
46 
52  function Length($NewVal = NULL) { return $this->GetOrSet("MyLength", $NewVal); }
53 
59  function Options($NewVal = NULL) { return $this->GetOrSet("MyOptions", $NewVal); }
60 
65 
70  function PrintInput($DisplayErrorIndicator = FALSE)
71  {
72  print("<select name=\"".$this->MyName."\" size=\"".$this->MyLength."\">\n");
73  foreach ($this->MyOptions as $OptionValue => $OptionLabel)
74  {
75  print(" <option value=\"".htmlspecialchars($OptionValue)."\""
76  .(($OptionValue == $this->Value()) ? " selected" : "")
77  .">".htmlspecialchars($OptionLabel)."\n");
78  }
79  print("</select>\n");
80  }
84  # ---- PRIVATE INTERFACE -------------------------------------------------
85 
86  private $MyLength;
87  private $MyOptions;
88 }
89 
90 ?>
Generator for HTML form fields.
Definition: FormField.php:14
FormField($Name, $IsRequired, $Label, $ValidFunc, $ValidMsgs)
Object Constructor.
Definition: FormField.php:32
Length($NewVal=NULL)
Get or set the length of the display field.
Options($NewVal=NULL)
Get or set the list of options displayed by this field.
PrintInput($DisplayErrorIndicator=FALSE)
Generate HTML representing this object.
Generator for option form fields.
OptionFormField($Name, $IsRequired, $Label, $Length, $Options, $ValidFunc=NULL, $ValidMsgs=NULL)
Object constructor.
Value($NewVal=NULL)
Get or set the form field value.
Definition: FormField.php:88