Source for file droplist.php

Documentation is available at droplist.php

  1. <?php
  2. /**
  3. * a dropdown selection list using a ChoiceList
  4. *
  5. @author    Stuart Prescott
  6. @copyright  Copyright Stuart Prescott
  7. @license    http://opensource.org/licenses/gpl-license.php GNU Public License
  8. @version    $Id$
  9. @package    Bumblebee
  10. @subpackage FormsLibrary
  11. */
  12.  
  13. /** Load ancillary functions */
  14. require_once 'inc/typeinfo.php';
  15.  
  16. /** parent object */
  17. require_once 'choicelist.php';
  18.  
  19. /**
  20. * a dropdown selection list using a ChoiceList
  21. *
  22. @package    Bumblebee
  23. @subpackage FormsLibrary
  24. */
  25. class DropList extends ChoiceList {
  26.  
  27.   /**
  28.   *  Create a new dropdown list object
  29.   *
  30.   * @param string $name   the name of the field (db name, and html field name
  31.   * @param string $description  used in the html title or longdesc for the field
  32.   */
  33.   function DropList($name$description=''{
  34.     //$this->DEBUG=10;
  35.     $this->ChoiceList($name$description);
  36.     $this->extendable = 0;
  37.   }
  38.  
  39.   function display({
  40.     return $this->selectable();
  41.   }
  42.  
  43.   function format($data{
  44.     //preDump($this->formatid);
  45.     //preDump($data);
  46.     $data['_field''0';
  47.     $selected ($data[$this->formatid== $this->getValue(" selected='1' " '');
  48.     $t  '<option '
  49.          ."value='".xssqw($data[$this->formatid])."$selected";
  50.     foreach (array_keys($this->formatteras $k{
  51.       $t .= $this->formatter[$k]->format($data);
  52.     }
  53.    $t .= "</option>\n";
  54.     return $t;
  55.   }
  56.  
  57.  
  58.   function selectable({
  59.     $t "<select name='$this->namebase$this->name'>";
  60.     foreach ($this->list->choicelist as $v{
  61.       $t .= $this->format($v);
  62.     }
  63.     $t .= "</select>";
  64.     return $t;
  65.   }
  66.  
  67.   function selectedValue({
  68.     $value $this->getValue();
  69.     foreach ($this->list->choicelist as $data{
  70.       if ($data[$this->formatid== $value{
  71.         break;
  72.       }
  73.     }
  74.     //preDump($data);
  75.     $t  '<input type="hidden" '
  76.           .'value="'.xssqw($data[$this->formatid]).'" /> ';
  77.     foreach (array_keys($this->formatteras $k{
  78.       $t .= $this->formatter[$k]->format($data);
  79.     }
  80.     $t .= "\n";
  81.     return $t;
  82.   }
  83.  
  84. // class DropList
  85.  
  86.  
  87. ?>

Documentation generated on Tue, 06 Mar 2007 10:01:23 +0000 by phpDocumentor 1.3.0