PhpExt : Form [ class tree ] [ index ] [ all elements ]

Source for file TriggerField.php

Documentation is available at TriggerField.php

  1. <?php
  2. /**
  3.  * PHP-Ext Library
  4.  * http://php-ext.googlecode.com
  5.  * @author Sergei Walter <sergeiw[at]gmail[dot]com>
  6.  * @copyright 2008 Sergei Walter
  7.  * @license http://www.gnu.org/licenses/lgpl.html
  8.  * @link http://php-ext.googlecode.com
  9.  * 
  10.  *  Reference for Ext JS: http://extjs.com
  11.  * 
  12.  */
  13.  
  14. /**
  15.  * @see PhpExt_TextField
  16.  */
  17. include_once 'PhpExt/Form/TextField.php';
  18.  
  19. /**
  20.  * Provides a convenient wrapper for TextFields that adds a clickable trigger button (looks like a combobox by default). The trigger has no default action, so you must assign a function to implement the trigger click handler by overriding onTriggerClick. You can create a TriggerField directly, as it renders exactly like a combobox for which you can provide a custom implementation. For example:
  21.  * <code>
  22.  * var trigger = new Ext.form.TriggerField();
  23.  * trigger.onTriggerClick = myTriggerFn;
  24.  * trigger.applyToMarkup('my-field');
  25.  * </code>
  26.  * However, in general you will most likely want to use TriggerField as the base class for a reusable component. Ext.form.DateField and Ext.form.ComboBox are perfect examples of this.
  27.  * @package PhpExt
  28.  * @subpackage Form
  29.  */
  30. {
  31.     // AutoCreate
  32.     /**
  33.      * A DomHelper element spec, or true for a default element spec (defaults to {tag: "input", type: "text", size: "16", autocomplete: "off"})
  34.      * @param PhpExt_Config_Config $value 
  35.      * @return PhpExt_Form_TriggerField 
  36.      */
  37.     public function setAutoCreate(PhpExt_Config_ConfigObject $value{
  38.         return parent::setAutoCreate($value);
  39.     }    
  40.     /**
  41.      * A DomHelper element spec, or true for a default element spec (defaults to {tag: "input", type: "text", size: "16", autocomplete: "off"})
  42.      * @return PhpExt_Config_Config 
  43.      */
  44.     public function getAutoCreate({
  45.         return parent::getAutoCreate();
  46.     }
  47.     
  48.     // HideTrigger
  49.     /**
  50.      * True to hide the trigger element and display only the base text field (defaults to false)
  51.      * @param boolean $value 
  52.      * @return PhpExt_Form_TriggerField 
  53.      */
  54.     public function setHideTrigger($value{
  55.         $this->setExtConfigProperty("hideTrigger"$value);
  56.         return $this;
  57.     }    
  58.     /**
  59.      * True to hide the trigger element and display only the base text field (defaults to false)
  60.      * @return boolean 
  61.      */
  62.     public function getHideTrigger({
  63.         return $this->getExtConfigProperty("hideTrigger");
  64.     }
  65.     
  66.     // TriggerCssClass
  67.     /**
  68.      * A CSS class to apply to the trigger
  69.      * @param string $value 
  70.      * @return PhpExt_Form_TriggerField 
  71.      */
  72.     public function setTriggerCssClass($value{
  73.         $this->setExtConfigProperty("triggerClass"$value);
  74.         return $this;
  75.     }    
  76.     /**
  77.      * A CSS class to apply to the trigger
  78.      * @return string 
  79.      */
  80.     public function getTriggerCssClass({
  81.         return $this->getExtConfigProperty("triggerClass");
  82.     
  83.     
  84.     public function __construct({
  85.         parent::__construct();
  86.         $this->setExtClassInfo("Ext.form.TriggerField","triggerfield");
  87.         
  88.         $validProps array(
  89.             "autoCreate",
  90.             "hideTrigger",
  91.             "triggerClass"
  92.         );
  93.         $this->addValidConfigProperties($validProps);
  94.         
  95.     }         
  96.  
  97.     /**
  98.      * Helper function to create a TriggerField.  Useful for quick adding it to a ComponentCollection
  99.      *
  100.      * @param string $name The field's HTML name attribute.
  101.      * @param string $label The label text to display next to this field (defaults to '')
  102.      * @param string $id The unique id of this component (defaults to an auto-assigned id).
  103.      * @return PhpExt_Form_TriggerField 
  104.      */
  105.     public static function createTriggerField($name$label null$id null{
  106.         $c new PhpExt_Form_TriggerField();
  107.         $c->setName($name);
  108.         if ($label !== null)
  109.           $c->setFieldLabel($label);
  110.         if ($id !== null)
  111.           $c->setId($id);
  112.         return $c;
  113.     }
  114. }

Documentation generated on Fri, 08 Aug 2008 16:02:20 -0500 by phpDocumentor 1.4.0