[ Index ]
 

Code source de PRADO 3.0.6

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/framework/Web/UI/ -> TForm.php (source)

   1  <?php
   2  /**
   3   * TForm class file
   4   *
   5   * @author Qiang Xue <qiang.xue@gmail.com>
   6   * @link http://www.pradosoft.com/
   7   * @copyright Copyright &copy; 2005 PradoSoft
   8   * @license http://www.pradosoft.com/license/
   9   * @version $Id: TForm.php 1397 2006-09-07 07:55:53Z wei $
  10   * @package System.Web.UI
  11   */
  12  
  13  /**
  14   * TForm class
  15   *
  16   * TForm displays an HTML form. Besides regular body content,
  17   * it displays hidden fields, javascript blocks and files that are registered
  18   * through {@link TClientScriptManager}.
  19   *
  20   * A TForm is required for a page that needs postback.
  21   * Each page can contain at most one TForm. If multiple HTML forms are needed,
  22   * please use regular HTML form tags for those forms that post to different
  23   * URLs.
  24   *
  25   * @author Qiang Xue <qiang.xue@gmail.com>
  26   * @version $Id: TForm.php 1397 2006-09-07 07:55:53Z wei $
  27   * @package System.Web.UI
  28   * @since 3.0
  29   */
  30  class TForm extends TControl
  31  {
  32      /**
  33       * Registers the form with the page.
  34       * @param mixed event parameter
  35       */
  36  	public function onInit($param)
  37      {
  38          parent::onInit($param);
  39          $this->getPage()->setForm($this);
  40      }
  41  
  42      /**
  43       * Adds form specific attributes to renderer.
  44       * @param THtmlWriter writer
  45       */
  46  	protected function addAttributesToRender($writer)
  47      {
  48          $writer->addAttribute('id',$this->getClientID());
  49          $writer->addAttribute('method',$this->getMethod());
  50          $writer->addAttribute('action',$this->getRequest()->getRequestURI());
  51          if(($enctype=$this->getEnctype())!=='')
  52              $writer->addAttribute('enctype',$enctype);
  53  
  54          $attributes=$this->getAttributes();
  55          $attributes->remove('action');
  56          $writer->addAttributes($attributes);
  57  
  58          if(($butt=$this->getDefaultButton())!=='')
  59          {
  60              if(($button=$this->findControl($butt))!==null)
  61                  $this->getPage()->getClientScript()->registerDefaultButton($this,$button);
  62              else
  63                  throw new TInvalidDataValueException('form_defaultbutton_invalid',$butt);
  64          }
  65      }
  66  
  67      /**
  68       * Renders the form.
  69       * @param THtmlWriter writer
  70       */
  71  	public function render($writer)
  72      {
  73          $this->addAttributesToRender($writer);
  74          $writer->renderBeginTag('form');
  75          $page=$this->getPage();
  76          $page->beginFormRender($writer);
  77          $this->renderChildren($writer);
  78          $page->endFormRender($writer);
  79          $writer->renderEndTag();
  80      }
  81  
  82      /**
  83       * @return string id path to the default button control.
  84       */
  85  	public function getDefaultButton()
  86      {
  87          return $this->getViewState('DefaultButton','');
  88      }
  89  
  90      /**
  91       * Sets a button to be default one in a form.
  92       * A default button will be clicked if a user presses 'Enter' key within
  93       * the form.
  94       * @param string id path to the default button control.
  95       */
  96  	public function setDefaultButton($value)
  97      {
  98          $this->setViewState('DefaultButton',$value,'');
  99      }
 100  
 101      /**
 102       * @return string form submission method. Defaults to 'post'.
 103       */
 104  	public function getMethod()
 105      {
 106          return $this->getViewState('Method','post');
 107      }
 108  
 109      /**
 110       * @param string form submission method. Valid values include 'post' and 'get'.
 111       */
 112  	public function setMethod($value)
 113      {
 114          $this->setViewState('Method',TPropertyValue::ensureEnum($value,'post','get'),'post');
 115      }
 116  
 117      /**
 118       * @return string the encoding type a browser uses to post data back to the server
 119       */
 120  	public function getEnctype()
 121      {
 122          return $this->getViewState('Enctype','');
 123      }
 124  
 125      /**
 126       * @param string the encoding type a browser uses to post data back to the server.
 127       * Commonly used types include
 128       * - application/x-www-form-urlencoded : Form data is encoded as name/value pairs. This is the standard encoding format.
 129       * - multipart/form-data : Form data is encoded as a message with a separate part for each control on the page.
 130       * - text/plain : Form data is encoded in plain text, without any control or formatting characters.
 131       */
 132  	public function setEnctype($value)
 133      {
 134          $this->setViewState('Enctype',$value,'');
 135      }
 136  
 137      /**
 138       * @return string form name, which is equal to {@link getUniqueID UniqueID}.
 139       */
 140  	public function getName()
 141      {
 142          return $this->getUniqueID();
 143      }
 144  }
 145  
 146  ?>


Généré le : Sun Feb 25 21:07:04 2007 par Balluche grâce à PHPXref 0.7