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

Source for file FormPanel.php

Documentation is available at FormPanel.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_Panel
  16.  */
  17. include_once 'PhpExt/Panel.php';
  18. /**
  19.  * @see PhpExt_Layout_FormLayout
  20.  */
  21. include_once 'PhpExt/Layout/FormLayout.php';
  22.  
  23. /**
  24.  * Standard form container.
  25.  * <p><b>Although they are not listed, this class also accepts all the config options required to configure its internal Ext.form.BasicForm</b></p>
  26.  * <p>FormPanel uses a Ext.layout.FormLayout internally, and that is required for fields and labels to work correctly within the FormPanel's layout. To nest additional layout styles within a FormPanel, you should nest additional Panels or other containers that can provide additional layout functionality. You should not override FormPanel's layout.</p>
  27.  * <p>By default, Ext Forms are submitted through Ajax, using Ext.form.Action. To enable normal browser submission of the Ext Form contained in this FormPanel, use the StandardSubmit property.
  28.  * @package PhpExt
  29.  * @subpackage Form
  30.  */
  31. {    
  32.     /**
  33.      * Display a quick tip when the user hovers over the field
  34.      *
  35.      */
  36.     const MSG_TARGET_QTIP = 'qtip';
  37.     /**
  38.      * Display a default browser title attribute popup
  39.      *
  40.      */
  41.     const MSG_TARGET_TITLE = 'title';
  42.     /**
  43.      * Add a block div beneath the field containing the error text
  44.      */
  45.     const MSG_TARGET_UNDER = 'under';
  46.     /**
  47.      * Add an error icon to the right of the field with a popup on hover
  48.      */
  49.     const MSG_TARGET_SIDE = 'side';
  50.  
  51.     const LABEL_ALIGN_LEFT = 'left';
  52.     const LABEL_ALIGN_TOP = 'top';
  53.     const LABEL_ALIGN_RIGHT = 'right';
  54.  
  55.     const METHOD_GET = 'GET';
  56.     const METHOD_POST = 'POST';
  57.  
  58.     const VTYPE_ALPHAMASK = 'alpha';
  59.     const VTYPE_ALPHANUM = 'alphanum';
  60.     const VTYPE_EMAIL = 'email';
  61.     const VTYPE_URL = 'url';
  62.  
  63.  
  64.     
  65.     // ButtonAlign
  66.     /**
  67.      * The alignment of any buttons added to this panel. Valid values are:
  68.      * - PhpExt_Ext::EXT_HALIGN_LEFT
  69.      * - PhpExt_Ext::EXT_HALIGN_RIGHT
  70.      * - PhpExt_Ext::EXT_HALIGN_CENTER
  71.      * Defaults to PhpExt_Ext::EXT_HALIGN_CENTER
  72.      * 
  73.      * @uses PhpExt_Ext::EXT_HALIGN_LEFT
  74.      * @uses PhpExt_Ext::EXT_HALIGN_RIGHT
  75.      * @uses PhpExt_Ext::EXT_HALIGN_CENTER
  76.      * @param string $value 
  77.      * @return PhpExt_Form_FormPanel 
  78.      */
  79.     public function setButtonAlign($value{
  80.         return parent::setButtonAlign($value);
  81.     }    
  82.     /**
  83.      * 
  84.      * @return string 
  85.      */
  86.     public function getButtonAlign({
  87.         return parent::getButtonAlign();
  88.     }
  89.     
  90.     // ItemCssClass
  91.     /**
  92.      * A css class to apply to the x-form-item of fields. This property cascades to child containers.
  93.      * @param string $value 
  94.      * @return PhpExt_Form_FormPanel 
  95.      */
  96.     public function setItemCssClass($value{
  97.         $this->setExtConfigProperty("itemCls"$value);
  98.         return $this;
  99.     }    
  100.     /**
  101.      * A css class to apply to the x-form-item of fields. This property cascades to child containers.
  102.      * @return string 
  103.      */
  104.     public function getItemCssClass({
  105.         return $this->getExtConfigProperty("itemCls");
  106.     }
  107.     
  108.     // LabelAlign
  109.     /**
  110.      * The alignment for the child controls' labels. Valid values are:
  111.      * - PhpExt_Form_FormPanel::LABEL_ALIGN_LEFT
  112.      * - PhpExt_Form_FormPanel::LABEL_ALIGN_TOP
  113.      * - PhpExt_Form_FormPanel::LABEL_ALIGN_RIGHT
  114.      * Defaults to PhpExt_Form_FormPanel::LABEL_ALIGN_LEFT.
  115.      * This property cascades to child containers if not set.
  116.      *  
  117.      * @uses PhpExt_Form_FormPanel::LABEL_ALIGN_LEFT
  118.      * @uses PhpExt_Form_FormPanel::LABEL_ALIGN_TOP
  119.      * @uses PhpExt_Form_FormPanel::LABEL_ALIGN_RIGHT
  120.      * @param string $value 
  121.      * @return PhpExt_Form_FormPanel 
  122.      */
  123.     public function setLabelAlign($value{
  124.         $this->setExtConfigProperty("labelAlign"$value);
  125.         return $this;
  126.     }    
  127.     /**
  128.      * 
  129.      * @return string 
  130.      */
  131.     public function getLabelAlign({
  132.         return $this->getExtConfigProperty("labelAlign");
  133.     }
  134.     
  135.     // LabelWidth
  136.     /**
  137.      * The width of labels. This property cascades to child containers.
  138.      * @param integer $value 
  139.      * @return PhpExt_Form_FormPanel 
  140.      */
  141.     public function setLabelWidth($value{
  142.         $this->setExtConfigProperty("labelWidth"$value);
  143.         return $this;
  144.     }    
  145.     /**
  146.      * The width of labels. This property cascades to child containers.
  147.      * @return integer 
  148.      */
  149.     public function getLabelWidth({
  150.         return $this->getExtConfigProperty("labelWidth");
  151.     }
  152.     
  153.     // MinButtonWidth
  154.     /**
  155.      * Minimum width of all buttons in pixels (defaults to 75)
  156.      * @param integer $value 
  157.      * @return PhpExt_Form_FormPanel 
  158.      */
  159.     public function setMinButtonWidth($value{
  160.         $this->setExtConfigProperty("minButtonWidth"$value);
  161.         return $this;
  162.     }    
  163.     /**
  164.      * Minimum width of all buttons in pixels (defaults to 75)
  165.      * @return integer 
  166.      */
  167.     public function getMinButtonWidth({
  168.         return $this->getExtConfigProperty("minButtonWidth");
  169.     }
  170.     
  171.     // MonitorPoll
  172.     /**
  173.      * The milliseconds to poll valid state, ignored if monitorValid is not true (defaults to 200)
  174.      * @param integer $value 
  175.      * @return PhpExt_Form_FormPanel 
  176.      */
  177.     public function setMonitorPoll($value{
  178.         $this->setExtConfigProperty("monitorPoll"$value);
  179.         return $this;
  180.     }    
  181.     /**
  182.      * The milliseconds to poll valid state, ignored if monitorValid is not true (defaults to 200)
  183.      * @return integer 
  184.      */
  185.     public function getMonitorPoll({
  186.         return $this->getExtConfigProperty("monitorPoll");
  187.     }
  188.     
  189.     // MonitorValid
  190.     /**
  191.      * If true the form monitors its valid state <b>client-side</b> and fires a looping event with that state. This is required to bind buttons to the valid state using the config value formBind:true on the button.
  192.      * @param boolean $value 
  193.      * @return PhpExt_Form_FormPanel 
  194.      */
  195.     public function setMonitorValid($value{
  196.         $this->setExtConfigProperty("monitorValid"$value);
  197.         return $this;
  198.     }    
  199.     /**
  200.      * If true the form monitors its valid state <b>client-side</b> and fires a looping event with that state. This is required to bind buttons to the valid state using the config value formBind:true on the button.
  201.      * @return boolean 
  202.      */
  203.     public function getMonitorValid({
  204.         return $this->getExtConfigProperty("monitorValid");
  205.     }
  206.  
  207.     /**#@+
  208.      * Internal BasicForm config properties:
  209.      * 
  210.      * The FormPanel uses a {@link PhpExt_Form_BasicForm} to handle actions like load, sumbit or reset.  
  211.      * BasicForm options may be included in the FormPanel Configuration for customization
  212.      * 
  213.      */
  214.  
  215.     // BaseParams
  216.     /**
  217.      * Parameters to pass with all requests. e.g. array('id'=>123, 'foo'=>'bar').
  218.      * @param array $value 
  219.      * @return PhpExt_Form_FormPanel 
  220.      */
  221.     public function setBaseParams($value{
  222.         $this->setExtConfigProperty("baseParams"$value);
  223.         return $this;
  224.     }    
  225.     /**
  226.      * Parameters to pass with all requests. e.g. array('id'=>123, 'foo'=>'bar').
  227.      * @return array 
  228.      */
  229.     public function getBaseParams({
  230.         return $this->getExtConfigProperty("baseParams");
  231.     }
  232.     
  233.     // ErrorReader
  234.     /**
  235.      * An {@link PhpExt_Data_DataReader} (e.g. {@link PhpExt_Data_XmlReader}) to be used to read data when reading validation errors on "submit" actions. This is completely optional as there is built-in support for processing JSON.
  236.      * @uses PhpExt_Data_DataReader
  237.      * @param PhpExt_Data_DataReader $value 
  238.      * @return PhpExt_Form_FormPanel 
  239.      */
  240.     public function setErrorReader($value{
  241.         $this->setExtConfigProperty("errorReader"$value);
  242.         return $this;
  243.     }    
  244.     /**
  245.      * 
  246.      * @return PhpExt_Data_DataReader 
  247.      */
  248.     public function getErrorReader({
  249.         return $this->getExtConfigProperty("errorReader");
  250.     }
  251.     
  252.     // FileUpload
  253.     /**
  254.      * Set to true if this form is a file upload.
  255.      * @param boolean $value 
  256.      * @return PhpExt_Form_FormPanel 
  257.      */
  258.     public function setFileUpload($value{
  259.         $this->setExtConfigProperty("fileUpload"$value);
  260.         return $this;
  261.     }    
  262.     /**
  263.      * Set to true if this form is a file upload.
  264.      * @return boolean 
  265.      */
  266.     public function getFileUpload({
  267.         return $this->getExtConfigProperty("fileUpload");
  268.     }
  269.     
  270.     // Method
  271.     /**
  272.      * The request method to use (GET or POST) for form actions if one isn't supplied in the action options.
  273.      * Posible values are:
  274.      *  - PhpExt_Form_FormPanel::METHOD_GET
  275.      *  - PhpExt_Form_FormPanel::METHOD_POST
  276.      * @uses PhpExt_Form_FormPanel::METHOD_GET
  277.      * @uses PhpExt_Form_FormPanel::METHOD_POST
  278.      * @param string $value 
  279.      * @return PhpExt_Form_FormPanel 
  280.      */
  281.     public function setMethod($value{
  282.         $this->setExtConfigProperty("method"$value);
  283.         return $this;
  284.     }    
  285.     /**
  286.      * The request method to use (GET or POST) for form actions if one isn't supplied in the action options.
  287.      * Posible values are:
  288.      *  - PhpExt_Form_FormPanel::METHOD_GET
  289.      *  - PhpExt_Form_FormPanel::METHOD_POST
  290.      * @uses PhpExt_Form_FormPanel::METHOD_GET
  291.      * @uses PhpExt_Form_FormPanel::METHOD_POST
  292.      * @return string 
  293.      */
  294.     public function getMethod({
  295.         return $this->getExtConfigProperty("method");
  296.     }
  297.     
  298.     // Reader
  299.     /**
  300.      * An {@link PhpExt_Data_DataReader} (e.g. {@link PhpExt_Data_XmlReader}) to be used to read data when executing "load" actions. This is optional as there is built-in support for processing JSON.
  301.      * @uses PhpExt_Data_DataReader
  302.      * @param PhpExt_Data_DataReader $value 
  303.      * @return PhpExt_Form_FormPanel 
  304.      */
  305.     public function setReader($value{
  306.         $this->setExtConfigProperty("reader"$value);
  307.         return $this;
  308.     }    
  309.     /**
  310.      * An {@link PhpExt_Data_DataReader} (e.g. {@link PhpExt_Data_XmlReader}) to be used to read data when executing "load" actions. This is optional as there is built-in support for processing JSON.
  311.      * @return PhpExt_Data_DataReader 
  312.      */
  313.     public function getReader({
  314.         return $this->getExtConfigProperty("reader");
  315.     }
  316.     
  317.     // StandardSubmit
  318.     /**
  319.      * If set to true, standard HTML form submits are used instead of XHR (Ajax) style form submissions. (defaults to false)
  320.      * @param boolean $value 
  321.      * @return PhpExt_Form_FormPanel 
  322.      */
  323.     public function setStandardSubmit($value{
  324.         $this->setExtConfigProperty("standardSubmit"$value);
  325.         return $this;
  326.     }    
  327.     /**
  328.      * If set to true, standard HTML form submits are used instead of XHR (Ajax) style form submissions. (defaults to false)
  329.      * @return boolean 
  330.      */
  331.     public function getStandardSubmit({
  332.         return $this->getExtConfigProperty("standardSubmit");
  333.     }
  334.     
  335.     // Timeout
  336.     /**
  337.      * Timeout for form actions in seconds (default is 30 seconds).
  338.      * @param integer $value 
  339.      * @return PhpExt_Form_FormPanel 
  340.      */
  341.     public function setTimeout($value{
  342.         $this->setExtConfigProperty("timeout"$value);
  343.         return $this;
  344.     }    
  345.     /**
  346.      * Timeout for form actions in seconds (default is 30 seconds).
  347.      * @return integer 
  348.      */
  349.     public function getTimeout({
  350.         return $this->getExtConfigProperty("timeout");
  351.     }
  352.     
  353.     // TrackResetOnLoad
  354.     /**
  355.      * If set to true, form.reset() resets to the last loaded or setValues() data instead of when the form was first created.
  356.      * @param boolean $value 
  357.      * @return PhpExt_Form_FormPanel 
  358.      */
  359.     public function setTrackResetOnload($value{
  360.         $this->setExtConfigProperty("trackResetOnLoad"$value);
  361.         return $this;
  362.     }    
  363.     /**
  364.      * If set to true, form.reset() resets to the last loaded or setValues() data instead of when the form was first created.
  365.      * @return boolean 
  366.      */
  367.     public function getTrackResetOnLoad({
  368.         return $this->getExtConfigProperty("trackResetOnLoad");
  369.     }
  370.     
  371.     // Url
  372.     /**
  373.      * The URL to use for form actions if one isn't supplied in the action options.
  374.      * @param string $value 
  375.      * @return PhpExt_Form_FormPanel 
  376.      */
  377.     public function setUrl($value{
  378.         $this->setExtConfigProperty("url"$value);
  379.         return $this;
  380.     }    
  381.     /**
  382.      * The URL to use for form actions if one isn't supplied in the action options.
  383.      * @return string 
  384.      */
  385.     public function getUrl({
  386.         return $this->getExtConfigProperty("url");
  387.     }
  388.     
  389.     // WaitMsgTarget
  390.     /**
  391.      * The id of the DOM Element to use as the wait message target
  392.      * @param string $value 
  393.      * @return PhpExt_Form_FormPanel 
  394.      */
  395.     public function setWaitMsgTarget($value{        
  396.         $this->setExtConfigProperty("waitMsgTarget"$value);
  397.         return $this;
  398.     }    
  399.     /**
  400.      * The id of the DOM Element to use as the wait message target
  401.      * @return string 
  402.      */
  403.     public function getWaitMsgTarget({
  404.         return $this->getExtConfigProperty("waitMsgTarget");
  405.     }
  406.     
  407.     /**#@-*/
  408.  
  409.     // OnSubmit
  410.     /**
  411.      * Override for the onSubmit event. Use PhpExt_Javascript::stm("Ext.emptyFn") to avoid the default handler.
  412.      * @param PhpExt_JavascriptStm $value 
  413.      * @return PhpExt_Form_FormPanel 
  414.      */
  415.     public function setOnSubmit($value{        
  416.         $this->setExtConfigProperty("onSubmit"$value);
  417.         return $this;
  418.     }    
  419.     /**
  420.      * Override for the onSubmit event. Use PhpExt_Javascript::stm("Ext.emptyFn") to avoid the default handler
  421.      * @return PhpExt_JavascriptStm 
  422.      */
  423.     public function getOnSubmit({
  424.         return $this->getExtConfigProperty("onSubmit");
  425.     }
  426.     
  427.     public $FieldsLazyRender = true;
  428.     
  429.     public function __construct($id null$url null{
  430.         parent::__construct();
  431.         $this->setExtClassInfo("Ext.form.FormPanel","form");
  432.  
  433.         $validProps array(
  434.             "buttonAlign",
  435.             "itemCls",
  436.             "labelAlign",
  437.             "labelWidth",
  438.             "minButtonWidth",
  439.             "monitorPoll",
  440.             "monitorValid",
  441.             // BasicForm Properties
  442.             "baseParams",
  443.             "errorReader",
  444.             "fileUpload",
  445.             "method",
  446.             "reader",
  447.             "standardSubmit",
  448.             "timeout",
  449.             "trackResetOnLoad",
  450.             "url",
  451.             "waitMsgTarget",
  452.             "onSubmit"
  453.         );
  454.         $this->addValidConfigProperties($validProps);
  455.  
  456.         if ($id !== null)
  457.             $this->setId($id);
  458.         if ($url !== null)
  459.             $this->setUrl($url);
  460.  
  461.         $this->_defaultLayout = new PhpExt_Layout_FormLayout();
  462.         $this->setLayout($this->_defaultLayout);
  463.         
  464.     }
  465.         
  466.         
  467. }

Documentation generated on Fri, 08 Aug 2008 15:54:17 -0500 by phpDocumentor 1.4.0