[ Index ]

PHP Cross Reference of Limb3

title

Body

[close]

/wact/src/tags/form/ -> form_multiple.tag.php (source)

   1  <?php
   2  /*
   3   * Limb PHP Framework
   4   *
   5   * @link http://limb-project.com 
   6   * @copyright  Copyright &copy; 2004-2007 BIT(http://bit-creative.com)
   7   * @license    LGPL http://www.gnu.org/copyleft/lesser.html 
   8   */
   9  
  10  require_once('limb/wact/src/tags/form/form.tag.php');
  11  /**
  12   * This tag allows you to have several forms on a single page and to submit them on a single page
  13   * In this case your request will have a variable named after submitted form
  14   * with all form elements inside
  15   * @tag form_multiple
  16   * @suppress_attributes children_reuse_runat
  17   * @restrict_self_nesting
  18   * @package wact
  19   * @version $Id: form_multiple.tag.php 5945 2007-06-06 08:31:43Z pachanga $
  20   */
  21  class WactFormMultipleTag extends WactFormTag
  22  {
  23    protected $runtimeComponentName = 'WactMultipleFormComponent';
  24    protected $runtimeIncludeFile = 'limb/wact/src/components/form/WactMultipleFormComponent.class.php';
  25  
  26    function prepare()
  27    {
  28      parent :: prepare();
  29  
  30      if(!$form_name = $this->getAttribute('name'))//should we leave it like that?
  31        return;
  32  
  33      $this->_renameChildren($form_name, $this->children);
  34  
  35      $this->tag = 'form';
  36    }
  37  
  38    function _renameChildren($form_name, $children)
  39    {
  40      foreach($children as $child)
  41      {
  42        if(is_a($child, 'WactControlTag') && ($name = $child->getAttribute('name')))
  43        {
  44          $child->removeAttribute('name');
  45          $child->setAttribute('name', $form_name . $this->_makeWrappedName($name));
  46        }
  47  
  48        if(sizeof($child->children) > 0)
  49          $this->_renameChildren($form_name, $child->children);
  50      }
  51    }
  52  
  53    function _makeWrappedName($name)
  54    {
  55      return preg_replace('/^([^\[\]]+)(\[.*\])*$/', "[\\1]\\2", $name);
  56    }
  57  
  58  }
  59  ?>


Generated: Tue Oct 7 05:02:03 2008 Cross-referenced by PHPXref 0.7