CWIS Developer Documentation
OptionFormField.php
Go to the documentation of this file.
1 <?PHP
2 
8 class OptionFormField extends FormField {
9 
10  # ---- PUBLIC INTERFACE --------------------------------------------------
11 
14 
25  function OptionFormField(
26  $Name, $IsRequired, $Label, $Length, $Options,
27  $ValidFunc = NULL, $ValidMsgs = NULL)
28  {
29  $this->MyLength = $Length;
30  $this->MyOptions = $Options;
31 
32  $this->FormField($Name, $IsRequired, $Label, $ValidFunc, $ValidMsgs);
33  }
38 
44  function Length($NewVal = NULL) { return $this->GetOrSet("MyLength", $NewVal); }
45 
51  function Options($NewVal = NULL) { return $this->GetOrSet("MyOptions", $NewVal); }
52 
57 
62  function PrintInput($DisplayErrorIndicator = FALSE)
63  {
64  print("<select name=\"".$this->MyName."\" size=\"".$this->MyLength."\">\n");
65  foreach ($this->MyOptions as $OptionValue => $OptionLabel)
66  {
67  print(" <option value=\"".htmlspecialchars($OptionValue)."\""
68  .(($OptionValue == $this->Value()) ? " selected" : "")
69  .">".htmlspecialchars($OptionLabel)."\n");
70  }
71  print("</select>\n");
72  }
76  # ---- PRIVATE INTERFACE -------------------------------------------------
77 
78  private $MyLength;
79  private $MyOptions;
80 }
81 
82 ?>