CWIS Developer Documentation
OptionFormField.php
Go to the documentation of this file.
1 <?PHP
2 #
3 # FILE: OptionFormField.php
4 #
5 # Part of the Collection Workflow Integration System (CWIS)
6 # Copyright 2013-2015 Edward Almasy and Internet Scout Research Group
7 # http://scout.wisc.edu/cwis/
8 #
9 
15 {
16 
17  # ---- PUBLIC INTERFACE --------------------------------------------------
18 
21 
32  public function __construct(
33  $Name, $IsRequired, $Label, $Length, $Options,
34  $ValidFunc = NULL, $ValidMsgs = NULL)
35  {
36  $this->MyLength = $Length;
37  $this->MyOptions = $Options;
38 
39  parent::__construct($Name, $IsRequired, $Label, $ValidFunc, $ValidMsgs);
40  }
45 
51  public function Length($NewVal = NULL)
52  {
53  return $this->GetOrSet("MyLength", $NewVal);
54  }
55 
61  public function Options($NewVal = NULL)
62  {
63  return $this->GetOrSet("MyOptions", $NewVal);
64  }
65 
70 
75  public function PrintInput($DisplayErrorIndicator = FALSE)
76  {
77  print("<select name=\"".$this->MyName."\" size=\"".$this->MyLength."\">\n");
78  foreach ($this->MyOptions as $OptionValue => $OptionLabel)
79  {
80  print(" <option value=\"".htmlspecialchars($OptionValue)."\""
81  .(($OptionValue == $this->Value()) ? " selected" : "")
82  .">".htmlspecialchars($OptionLabel)."\n");
83  }
84  print("</select>\n");
85  }
89  # ---- PRIVATE INTERFACE -------------------------------------------------
90 
91  private $MyLength;
92  private $MyOptions;
93 }
94 
__construct($Name, $IsRequired, $Label, $Length, $Options, $ValidFunc=NULL, $ValidMsgs=NULL)
Object constructor.
Generator for HTML form fields.
Definition: FormField.php:14
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.
Value($NewVal=NULL)
Get or set the form field value.
Definition: FormField.php:97