Changeset 926

Show
Ignore:
Timestamp:
05/05/08 08:46:36 (3 months ago)
Author:
laurentj
Message:

jforms-groups: worked on the <group> control

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/experimental/jforms-groups/lib/jelix/forms/jFormsBase.class.php

    r920 r926  
    4848     * @see jFormsControl 
    4949     */ 
    50     protected $topControls = array(); 
     50    protected $rootControls = array(); 
    5151 
    5252    /** 
     
    134134        $req = $GLOBALS['gJCoord']->request; 
    135135        $this->modifiedControls=array(); 
    136         foreach($this->topControls as $name=>$ctrl){ 
     136        foreach($this->rootControls as $name=>$ctrl){ 
    137137            if(!$this->container->isActivated($name) || $this->container->isReadOnly($name)) 
    138138                continue; 
     
    492492    public function getContainer(){ return $this->container; } 
    493493 
     494 
     495    /** 
     496     * @return array of jFormsControl objects 
     497     */ 
     498    public function getRootControls(){ return $this->rootControls; } 
     499 
    494500    /** 
    495501     * @return array of jFormsControl objects 
     
    627633    */ 
    628634    public function addControl($control){ 
    629         $this->topControls [$control->ref] = $control; 
     635        $this->rootControls [$control->ref] = $control; 
    630636        $this->addChildControl($control); 
    631637 
     
    638644 
    639645    function removeControl($name) { 
    640         if(!isset($this->topControls [$name])) 
     646        if(!isset($this->rootControls [$name])) 
    641647            return; 
    642         unset($this->topControls [$name]); 
     648        unset($this->rootControls [$name]); 
    643649        unset($this->controls [$name]); 
    644650        unset($this->submits [$name]); 
  • branches/experimental/jforms-groups/lib/jelix/forms/jFormsBase.class.php

    r920 r926  
    4848     * @see jFormsControl 
    4949     */ 
    50     protected $topControls = array(); 
     50    protected $rootControls = array(); 
    5151 
    5252    /** 
     
    134134        $req = $GLOBALS['gJCoord']->request; 
    135135        $this->modifiedControls=array(); 
    136         foreach($this->topControls as $name=>$ctrl){ 
     136        foreach($this->rootControls as $name=>$ctrl){ 
    137137            if(!$this->container->isActivated($name) || $this->container->isReadOnly($name)) 
    138138                continue; 
     
    492492    public function getContainer(){ return $this->container; } 
    493493 
     494 
     495    /** 
     496     * @return array of jFormsControl objects 
     497     */ 
     498    public function getRootControls(){ return $this->rootControls; } 
     499 
    494500    /** 
    495501     * @return array of jFormsControl objects 
     
    627633    */ 
    628634    public function addControl($control){ 
    629         $this->topControls [$control->ref] = $control; 
     635        $this->rootControls [$control->ref] = $control; 
    630636        $this->addChildControl($control); 
    631637 
     
    638644 
    639645    function removeControl($name) { 
    640         if(!isset($this->topControls [$name])) 
     646        if(!isset($this->rootControls [$name])) 
    641647            return; 
    642         unset($this->topControls [$name]); 
     648        unset($this->rootControls [$name]); 
    643649        unset($this->controls [$name]); 
    644650        unset($this->submits [$name]); 
  • branches/experimental/jforms-groups/lib/jelix/forms/jFormsBase.class.php

    r920 r926  
    4848     * @see jFormsControl 
    4949     */ 
    50     protected $topControls = array(); 
     50    protected $rootControls = array(); 
    5151 
    5252    /** 
     
    134134        $req = $GLOBALS['gJCoord']->request; 
    135135        $this->modifiedControls=array(); 
    136         foreach($this->topControls as $name=>$ctrl){ 
     136        foreach($this->rootControls as $name=>$ctrl){ 
    137137            if(!$this->container->isActivated($name) || $this->container->isReadOnly($name)) 
    138138                continue; 
     
    492492    public function getContainer(){ return $this->container; } 
    493493 
     494 
     495    /** 
     496     * @return array of jFormsControl objects 
     497     */ 
     498    public function getRootControls(){ return $this->rootControls; } 
     499 
    494500    /** 
    495501     * @return array of jFormsControl objects 
     
    627633    */ 
    628634    public function addControl($control){ 
    629         $this->topControls [$control->ref] = $control; 
     635        $this->rootControls [$control->ref] = $control; 
    630636        $this->addChildControl($control); 
    631637 
     
    638644 
    639645    function removeControl($name) { 
    640         if(!isset($this->topControls [$name])) 
     646        if(!isset($this->rootControls [$name])) 
    641647            return; 
    642         unset($this->topControls [$name]); 
     648        unset($this->rootControls [$name]); 
    643649        unset($this->controls [$name]); 
    644650        unset($this->submits [$name]); 
  • branches/experimental/jforms-groups/lib/jelix/forms/jFormsBase.class.php

    r920 r926  
    4848     * @see jFormsControl 
    4949     */ 
    50     protected $topControls = array(); 
     50    protected $rootControls = array(); 
    5151 
    5252    /** 
     
    134134        $req = $GLOBALS['gJCoord']->request; 
    135135        $this->modifiedControls=array(); 
    136         foreach($this->topControls as $name=>$ctrl){ 
     136        foreach($this->rootControls as $name=>$ctrl){ 
    137137            if(!$this->container->isActivated($name) || $this->container->isReadOnly($name)) 
    138138                continue; 
     
    492492    public function getContainer(){ return $this->container; } 
    493493 
     494 
     495    /** 
     496     * @return array of jFormsControl objects 
     497     */ 
     498    public function getRootControls(){ return $this->rootControls; } 
     499 
    494500    /** 
    495501     * @return array of jFormsControl objects 
     
    627633    */ 
    628634    public function addControl($control){ 
    629         $this->topControls [$control->ref] = $control; 
     635        $this->rootControls [$control->ref] = $control; 
    630636        $this->addChildControl($control); 
    631637 
     
    638644 
    639645    function removeControl($name) { 
    640         if(!isset($this->topControls [$name])) 
     646        if(!isset($this->rootControls [$name])) 
    641647            return; 
    642         unset($this->topControls [$name]); 
     648        unset($this->rootControls [$name]); 
    643649        unset($this->controls [$name]); 
    644650        unset($this->submits [$name]); 
  • branches/experimental/jforms-groups/lib/jelix/forms/jFormsControl.class.php

    r920 r926  
    534534            $ctrl->check($this); 
    535535        } 
    536         return $r
     536        return $v
    537537    } 
    538538 
  • branches/experimental/jforms-groups/lib/jelix/forms/jFormsControl.class.php

    r920 r926  
    534534            $ctrl->check($this); 
    535535        } 
    536         return $r
     536        return $v
    537537    } 
    538538 
  • branches/experimental/jforms-groups/lib/jelix/forms/jFormsControl.class.php

    r920 r926  
    534534            $ctrl->check($this); 
    535535        } 
    536         return $r
     536        return $v
    537537    } 
    538538 
  • branches/experimental/jforms-groups/lib/jelix/forms/jFormsControl.class.php

    r920 r926  
    534534            $ctrl->check($this); 
    535535        } 
    536         return $r
     536        return $v
    537537    } 
    538538 
  • branches/experimental/jforms-groups/lib/jelix/plugins/jforms/html/html.jformsbuilder.php

    r914 r926  
    2121 
    2222        echo '<table class="jforms-table" border="0">'; 
    23         foreach( $this->_form->getControls() as $ctrlref=>$ctrl){ 
     23        foreach( $this->_form->getRootControls() as $ctrlref=>$ctrl){ 
    2424            if($ctrl->type == 'submit' || $ctrl->type == 'reset' || $ctrl->type == 'hidden') continue; 
    2525            if(!$this->_form->isActivated($ctrlref)) continue; 
    26             echo '<tr><th scope="row">'; 
    27             $this->outputControlLabel($ctrl); 
    28             echo '</th><td>'; 
    29             $this->outputControl($ctrl); 
    30             echo '</td></tr>'; 
     26            if($ctrl->type == 'group') { 
     27                echo '<tr><td colspan="2">'; 
     28                $this->outputControl($ctrl); 
     29                echo '</td></tr>'; 
     30            }else{ 
     31                echo '<tr><th scope="row">'; 
     32                $this->outputControlLabel($ctrl); 
     33                echo '</th><td>'; 
     34                $this->outputControl($ctrl); 
     35                echo '</td></tr>'; 
     36            } 
    3137        } 
    3238        echo '</table> <div class="jforms-submit-buttons">'; 
     
    137143 
    138144    public function outputControlLabel($ctrl){ 
    139         if($ctrl->type == 'hidden') return; 
     145        if($ctrl->type == 'hidden' || $ctrl->type == 'group') return; 
    140146        $required = ($ctrl->required == ''|| $ctrl->isReadOnly()?'':' jforms-required'); 
    141147        $inError = (isset($this->_form->getContainer()->errors[$ctrl->ref]) ?' jforms-error':''); 
     
    145151        }else if($ctrl->type != 'submit' && $ctrl->type != 'reset'){ 
    146152            $id = $this->_name.'_'.$ctrl->ref; 
    147             echo '<label class="jforms-label',$required,$inError,'" for="'.$id.'"',$hint,'>'.htmlspecialchars($ctrl->label).'</label>'; 
     153            echo '<label class="jforms-label',$required,$inError,'" for="',$id,'"',$hint,'>',htmlspecialchars($ctrl->label),'</label>'; 
    148154        } 
    149155    } 
     
    352358    } 
    353359 
     360    protected function outputGroup($ctrl, $id, $class, $readonly, $hint) { 
     361        echo '<fieldset><legend>',htmlspecialchars($ctrl->label),'</legend>',"\n"; 
     362        echo '<table class="jforms-table-group" border="0">'; 
     363        foreach( $ctrl->getChildControls() as $ctrlref=>$c){ 
     364            if($c->type == 'submit' || $c->type == 'reset' || $c->type == 'hidden') continue; 
     365            if(!$this->_form->isActivated($ctrlref)) continue; 
     366            echo '<tr><th scope="row">'; 
     367            $this->outputControlLabel($c); 
     368            echo '</th><td>'; 
     369            $this->outputControl($c); 
     370            echo '</td></tr>'; 
     371        } 
     372        echo '</table></fieldset>'; 
     373    } 
     374 
    354375    protected function outputHelp($ctrl) { 
    355376        if ($ctrl->hasHelp) { 
  • branches/experimental/jforms-groups/lib/jelix/plugins/jforms/html/html.jformsbuilder.php

    r914 r926  
    2121 
    2222        echo '<table class="jforms-table" border="0">'; 
    23         foreach( $this->_form->getControls() as $ctrlref=>$ctrl){ 
     23        foreach( $this->_form->getRootControls() as $ctrlref=>$ctrl){ 
    2424            if($ctrl->type == 'submit' || $ctrl->type == 'reset' || $ctrl->type == 'hidden') continue; 
    2525            if(!$this->_form->isActivated($ctrlref)) continue; 
    26             echo '<tr><th scope="row">'; 
    27             $this->outputControlLabel($ctrl); 
    28             echo '</th><td>'; 
    29             $this->outputControl($ctrl); 
    30             echo '</td></tr>'; 
     26            if($ctrl->type == 'group') { 
     27                echo '<tr><td colspan="2">'; 
     28                $this->outputControl($ctrl); 
     29                echo '</td></tr>'; 
     30            }else{ 
     31                echo '<tr><th scope="row">'; 
     32                $this->outputControlLabel($ctrl); 
     33                echo '</th><td>'; 
     34                $this->outputControl($ctrl); 
     35                echo '</td></tr>'; 
     36            } 
    3137        } 
    3238        echo '</table> <div class="jforms-submit-buttons">'; 
     
    137143 
    138144    public function outputControlLabel($ctrl){ 
    139         if($ctrl->type == 'hidden') return; 
     145        if($ctrl->type == 'hidden' || $ctrl->type == 'group') return; 
    140146        $required = ($ctrl->required == ''|| $ctrl->isReadOnly()?'':' jforms-required'); 
    141147        $inError = (isset($this->_form->getContainer()->errors[$ctrl->ref]) ?' jforms-error':''); 
     
    145151        }else if($ctrl->type != 'submit' && $ctrl->type != 'reset'){ 
    146152            $id = $this->_name.'_'.$ctrl->ref; 
    147             echo '<label class="jforms-label',$required,$inError,'" for="'.$id.'"',$hint,'>'.htmlspecialchars($ctrl->label).'</label>'; 
     153            echo '<label class="jforms-label',$required,$inError,'" for="',$id,'"',$hint,'>',htmlspecialchars($ctrl->label),'</label>'; 
    148154        } 
    149155    } 
     
    352358    } 
    353359 
     360    protected function outputGroup($ctrl, $id, $class, $readonly, $hint) { 
     361        echo '<fieldset><legend>',htmlspecialchars($ctrl->label),'</legend>',"\n"; 
     362        echo '<table class="jforms-table-group" border="0">'; 
     363        foreach( $ctrl->getChildControls() as $ctrlref=>$c){ 
     364            if($c->type == 'submit' || $c->type == 'reset' || $c->type == 'hidden') continue; 
     365            if(!$this->_form->isActivated($ctrlref)) continue; 
     366            echo '<tr><th scope="row">'; 
     367            $this->outputControlLabel($c); 
     368            echo '</th><td>'; 
     369            $this->outputControl($c); 
     370            echo '</td></tr>'; 
     371        } 
     372        echo '</table></fieldset>'; 
     373    } 
     374 
    354375    protected function outputHelp($ctrl) { 
    355376        if ($ctrl->hasHelp) { 
  • branches/experimental/jforms-groups/lib/jelix/plugins/jforms/html/html.jformsbuilder.php

    r914 r926  
    2121 
    2222        echo '<table class="jforms-table" border="0">'; 
    23         foreach( $this->_form->getControls() as $ctrlref=>$ctrl){ 
     23        foreach( $this->_form->getRootControls() as $ctrlref=>$ctrl){ 
    2424            if($ctrl->type == 'submit' || $ctrl->type == 'reset' || $ctrl->type == 'hidden') continue; 
    2525            if(!$this->_form->isActivated($ctrlref)) continue; 
    26             echo '<tr><th scope="row">'; 
    27             $this->outputControlLabel($ctrl); 
    28             echo '</th><td>'; 
    29             $this->outputControl($ctrl); 
    30             echo '</td></tr>'; 
     26            if($ctrl->type == 'group') { 
     27                echo '<tr><td colspan="2">'; 
     28                $this->outputControl($ctrl); 
     29                echo '</td></tr>'; 
     30            }else{ 
     31                echo '<tr><th scope="row">'; 
     32                $this->outputControlLabel($ctrl); 
     33                echo '</th><td>'; 
     34                $this->outputControl($ctrl); 
     35                echo '</td></tr>'; 
     36            } 
    3137        } 
    3238        echo '</table> <div class="jforms-submit-buttons">'; 
     
    137143 
    138144    public function outputControlLabel($ctrl){ 
    139         if($ctrl->type == 'hidden') return; 
     145        if($ctrl->type == 'hidden' || $ctrl->type == 'group') return; 
    140146        $required = ($ctrl->required == ''|| $ctrl->isReadOnly()?'':' jforms-required'); 
    141147        $inError = (isset($this->_form->getContainer()->errors[$ctrl->ref]) ?' jforms-error':''); 
     
    145151        }else if($ctrl->type != 'submit' && $ctrl->type != 'reset'){ 
    146152            $id = $this->_name.'_'.$ctrl->ref; 
    147             echo '<label class="jforms-label',$required,$inError,'" for="'.$id.'"',$hint,'>'.htmlspecialchars($ctrl->label).'</label>'; 
     153            echo '<label class="jforms-label',$required,$inError,'" for="',$id,'"',$hint,'>',htmlspecialchars($ctrl->label),'</label>'; 
    148154        } 
    149155    } 
     
    352358    } 
    353359 
     360    protected function outputGroup($ctrl, $id, $class, $readonly, $hint) { 
     361        echo '<fieldset><legend>',htmlspecialchars($ctrl->label),'</legend>',"\n"; 
     362        echo '<table class="jforms-table-group" border="0">'; 
     363        foreach( $ctrl->getChildControls() as $ctrlref=>$c){ 
     364            if($c->type == 'submit' || $c->type == 'reset' || $c->type == 'hidden') continue; 
     365            if(!$this->_form->isActivated($ctrlref)) continue; 
     366            echo '<tr><th scope="row">'; 
     367            $this->outputControlLabel($c); 
     368            echo '</th><td>'; 
     369            $this->outputControl($c); 
     370            echo '</td></tr>'; 
     371        } 
     372        echo '</table></fieldset>'; 
     373    } 
     374 
    354375    protected function outputHelp($ctrl) { 
    355376        if ($ctrl->hasHelp) { 
  • branches/experimental/jforms-groups/lib/jelix/plugins/jforms/html/html.jformsbuilder.php

    r914 r926  
    2121 
    2222        echo '<table class="jforms-table" border="0">'; 
    23         foreach( $this->_form->getControls() as $ctrlref=>$ctrl){ 
     23        foreach( $this->_form->getRootControls() as $ctrlref=>$ctrl){ 
    2424            if($ctrl->type == 'submit' || $ctrl->type == 'reset' || $ctrl->type == 'hidden') continue; 
    2525            if(!$this->_form->isActivated($ctrlref)) continue; 
    26             echo '<tr><th scope="row">'; 
    27             $this->outputControlLabel($ctrl); 
    28             echo '</th><td>'; 
    29             $this->outputControl($ctrl); 
    30             echo '</td></tr>'; 
     26            if($ctrl->type == 'group') { 
     27                echo '<tr><td colspan="2">'; 
     28                $this->outputControl($ctrl); 
     29                echo '</td></tr>'; 
     30            }else{ 
     31                echo '<tr><th scope="row">'; 
     32                $this->outputControlLabel($ctrl); 
     33                echo '</th><td>'; 
     34                $this->outputControl($ctrl); 
     35                echo '</td></tr>'; 
     36            } 
    3137        } 
    3238        echo '</table> <div class="jforms-submit-buttons">'; 
     
    137143 
    138144    public function outputControlLabel($ctrl){ 
    139         if($ctrl->type == 'hidden') return; 
     145        if($ctrl->type == 'hidden' || $ctrl->type == 'group') return; 
    140146        $required = ($ctrl->required == ''|| $ctrl->isReadOnly()?'':' jforms-required'); 
    141147        $inError = (isset($this->_form->getContainer()->errors[$ctrl->ref]) ?' jforms-error':''); 
     
    145151        }else if($ctrl->type != 'submit' && $ctrl->type != 'reset'){ 
    146152            $id = $this->_name.'_'.$ctrl->ref; 
    147             echo '<label class="jforms-label',$required,$inError,'" for="'.$id.'"',$hint,'>'.htmlspecialchars($ctrl->label).'</label>'; 
     153            echo '<label class="jforms-label',$required,$inError,'" for="',$id,'"',$hint,'>',htmlspecialchars($ctrl->label),'</label>'; 
    148154        } 
    149155    } 
     
    352358    } 
    353359 
     360    protected function outputGroup($ctrl, $id, $class, $readonly, $hint) { 
     361        echo '<fieldset><legend>',htmlspecialchars($ctrl->label),'</legend>',"\n"; 
     362        echo '<table class="jforms-table-group" border="0">'; 
     363        foreach( $ctrl->getChildControls() as $ctrlref=>$c){ 
     364            if($c->type == 'submit' || $c->type == 'reset' || $c->type == 'hidden') continue; 
     365            if(!$this->_form->isActivated($ctrlref)) continue; 
     366            echo '<tr><th scope="row">'; 
     367            $this->outputControlLabel($c); 
     368            echo '</th><td>'; 
     369            $this->outputControl($c); 
     370            echo '</td></tr>'; 
     371        } 
     372        echo '</table></fieldset>'; 
     373    } 
     374 
    354375    protected function outputHelp($ctrl) { 
    355376        if ($ctrl->hasHelp) { 
  • branches/experimental/jforms-groups/lib/jelix/plugins/tpl/html/block.formcontrols.php

    r877 r926  
    7070        $content .= '$ctrls_notto_display=null;'; 
    7171    } 
    72  
     72    $_frmctrlInsideForm = $compiler->isInsideBlock('form'); 
    7373    $content .= ' 
    7474if (!isset($t->_privateVars[\'__displayed_ctrl\'])) { 
     
    7676} 
    7777$t->_privateVars[\'__ctrlref\']=\'\'; 
    78 $_frmctrlInsideForm = isset($t->_privateVars[\'__formbuilder\']); 
    79 foreach($t->_privateVars[\'__form\']->getControls() as $ctrlref=>$ctrl){ 
     78'; 
     79if($_frmctrlInsideForm){ 
     80    $list = 'getRootControls()'; 
     81}else{ 
     82    $list = 'getControls()'; 
     83
     84$content.=' 
     85foreach($t->_privateVars[\'__form\']->'.$list.' as $ctrlref=>$ctrl){ 
    8086    if(!$t->_privateVars[\'__form\']->isActivated($ctrlref)) continue; 
    81     if($ctrl->type == \'reset\' || $ctrl->type == \'hidden\') continue; 
    82     if($ctrl->type == \'submit\' && ($_frmctrlInsideForm || $ctrl->standalone)) continue; 
    83     if(!$_frmctrlInsideForm && ($ctrl->type == \'captcha\' || $ctrl->type == \'secretconfirm\') ) continue; 
    84     if(!isset($t->_privateVars[\'__displayed_ctrl\'][$ctrlref]) 
     87    if($ctrl->type == \'reset\' || $ctrl->type == \'hidden\') continue;'."\n"; 
     88    if(!$_frmctrlInsideForm) 
     89        $content.='if($ctrl->type == \'submit\' && $ctrl->standalone) continue; 
     90            if($ctrl->type == \'captcha\' || $ctrl->type == \'secretconfirm\') continue;'."\n"; 
     91    else  
     92        $content.='if($ctrl->type == \'submit\') continue;'; 
     93 
     94    $content.='if(!isset($t->_privateVars[\'__displayed_ctrl\'][$ctrlref]) 
    8595       && (  ($ctrls_to_display===null && $ctrls_notto_display === null) 
    8696          || ($ctrls_to_display===null && !in_array($ctrlref, $ctrls_notto_display)) 
  • branches/experimental/jforms-groups/lib/jelix/plugins/tpl/html/block.formcontrols.php

    r877 r926  
    7070        $content .= '$ctrls_notto_display=null;'; 
    7171    } 
    72  
     72    $_frmctrlInsideForm = $compiler->isInsideBlock('form'); 
    7373    $content .= ' 
    7474if (!isset($t->_privateVars[\'__displayed_ctrl\'])) { 
     
    7676} 
    7777$t->_privateVars[\'__ctrlref\']=\'\'; 
    78 $_frmctrlInsideForm = isset($t->_privateVars[\'__formbuilder\']); 
    79 foreach($t->_privateVars[\'__form\']->getControls() as $ctrlref=>$ctrl){ 
     78'; 
     79if($_frmctrlInsideForm){ 
     80    $list = 'getRootControls()'; 
     81}else{ 
     82    $list = 'getControls()'; 
     83
     84$content.=' 
     85foreach($t->_privateVars[\'__form\']->'.$list.' as $ctrlref=>$ctrl){ 
    8086    if(!$t->_privateVars[\'__form\']->isActivated($ctrlref)) continue; 
    81     if($ctrl->type == \'reset\' || $ctrl->type == \'hidden\') continue; 
    82     if($ctrl->type == \'submit\' && ($_frmctrlInsideForm || $ctrl->standalone)) continue; 
    83     if(!$_frmctrlInsideForm && ($ctrl->type == \'captcha\' || $ctrl->type == \'secretconfirm\') ) continue; 
    84     if(!isset($t->_privateVars[\'__displayed_ctrl\'][$ctrlref]) 
     87    if($ctrl->type == \'reset\' || $ctrl->type == \'hidden\') continue;'."\n"; 
     88    if(!$_frmctrlInsideForm) 
     89        $content.='if($ctrl->type == \'submit\' && $ctrl->standalone) continue; 
     90            if($ctrl->type == \'captcha\' || $ctrl->type == \'secretconfirm\') continue;'."\n"; 
     91    else  
     92        $content.='if($ctrl->type == \'submit\') continue;'; 
     93 
     94    $content.='if(!isset($t->_privateVars[\'__displayed_ctrl\'][$ctrlref]) 
    8595       && (  ($ctrls_to_display===null && $ctrls_notto_display === null) 
    8696          || ($ctrls_to_display===null && !in_array($ctrlref, $ctrls_notto_display)) 
  • branches/experimental/jforms-groups/lib/jelix/plugins/tpl/html/block.formcontrols.php

    r877 r926  
    7070        $content .= '$ctrls_notto_display=null;'; 
    7171    } 
    72  
     72    $_frmctrlInsideForm = $compiler->isInsideBlock('form'); 
    7373    $content .= ' 
    7474if (!isset($t->_privateVars[\'__displayed_ctrl\'])) { 
     
    7676} 
    7777$t->_privateVars[\'__ctrlref\']=\'\'; 
    78 $_frmctrlInsideForm = isset($t->_privateVars[\'__formbuilder\']); 
    79 foreach($t->_privateVars[\'__form\']->getControls() as $ctrlref=>$ctrl){ 
     78'; 
     79if($_frmctrlInsideForm){ 
     80    $list = 'getRootControls()'; 
     81}else{ 
     82    $list = 'getControls()'; 
     83
     84$content.=' 
     85foreach($t->_privateVars[\'__form\']->'.$list.' as $ctrlref=>$ctrl){ 
    8086    if(!$t->_privateVars[\'__form\']->isActivated($ctrlref)) continue; 
    81     if($ctrl->type == \'reset\' || $ctrl->type == \'hidden\') continue; 
    82     if($ctrl->type == \'submit\' && ($_frmctrlInsideForm || $ctrl->standalone)) continue; 
    83     if(!$_frmctrlInsideForm && ($ctrl->type == \'captcha\' || $ctrl->type == \'secretconfirm\') ) continue; 
    84     if(!isset($t->_privateVars[\'__displayed_ctrl\'][$ctrlref]) 
     87    if($ctrl->type == \'reset\' || $ctrl->type == \'hidden\') continue;'."\n"; 
     88    if(!$_frmctrlInsideForm) 
     89        $content.='if($ctrl->type == \'submit\' && $ctrl->standalone) continue; 
     90            if($ctrl->type == \'captcha\' || $ctrl->type == \'secretconfirm\') continue;'."\n"; 
     91    else  
     92        $content.='if($ctrl->type == \'submit\') continue;'; 
     93 
     94    $content.='if(!isset($t->_privateVars[\'__displayed_ctrl\'][$ctrlref]) 
    8595       && (  ($ctrls_to_display===null && $ctrls_notto_display === null) 
    8696          || ($ctrls_to_display===null && !in_array($ctrlref, $ctrls_notto_display)) 
  • branches/experimental/jforms-groups/lib/jelix/plugins/tpl/html/block.formcontrols.php

    r877 r926  
    7070        $content .= '$ctrls_notto_display=null;'; 
    7171    } 
    72  
     72    $_frmctrlInsideForm = $compiler->isInsideBlock('form'); 
    7373    $content .= ' 
    7474if (!isset($t->_privateVars[\'__displayed_ctrl\'])) { 
     
    7676} 
    7777$t->_privateVars[\'__ctrlref\']=\'\'; 
    78 $_frmctrlInsideForm = isset($t->_privateVars[\'__formbuilder\']); 
    79 foreach($t->_privateVars[\'__form\']->getControls() as $ctrlref=>$ctrl){ 
     78'; 
     79if($_frmctrlInsideForm){ 
     80    $list = 'getRootControls()'; 
     81}else{ 
     82    $list = 'getControls()'; 
     83
     84$content.=' 
     85foreach($t->_privateVars[\'__form\']->'.$list.' as $ctrlref=>$ctrl){ 
    8086    if(!$t->_privateVars[\'__form\']->isActivated($ctrlref)) continue; 
    81     if($ctrl->type == \'reset\' || $ctrl->type == \'hidden\') continue; 
    82     if($ctrl->type == \'submit\' && ($_frmctrlInsideForm || $ctrl->standalone)) continue; 
    83     if(!$_frmctrlInsideForm && ($ctrl->type == \'captcha\' || $ctrl->type == \'secretconfirm\') ) continue; 
    84     if(!isset($t->_privateVars[\'__displayed_ctrl\'][$ctrlref]) 
     87    if($ctrl->type == \'reset\' || $ctrl->type == \'hidden\') continue;'."\n"; 
     88    if(!$_frmctrlInsideForm) 
     89        $content.='if($ctrl->type == \'submit\' && $ctrl->standalone) continue; 
     90            if($ctrl->type == \'captcha\' || $ctrl->type == \'secretconfirm\') continue;'."\n"; 
     91    else  
     92        $content.='if($ctrl->type == \'submit\') continue;'; 
     93 
     94    $content.='if(!isset($t->_privateVars[\'__displayed_ctrl\'][$ctrlref]) 
    8595       && (  ($ctrls_to_display===null && $ctrls_notto_display === null) 
    8696          || ($ctrls_to_display===null && !in_array($ctrlref, $ctrls_notto_display)) 
  • branches/experimental/jforms-groups/lib/jelix/tpl/jTplCompiler.class.php

    r892 r926  
    393393        } 
    394394        return $res; 
     395    } 
     396 
     397    /** 
     398     * for plugins, it says if the plugin is inside the given block 
     399     * @param string $blockName the block to search 
     400     * @param boolean $onlyUpper check only the upper block 
     401     * @return boolean  true if it is inside the block 
     402     */ 
     403    public function isInsideBlock($blockName, $onlyUpper=false) { 
     404        if($onlyUpper) 
     405            return (end($this->_blockStack) == $blockName); 
     406        for($i=count($this->_blockStack) -1; $i>=0; $i--) { 
     407            if($this->_blockStack[$i] == $blockName) 
     408                return true; 
     409        } 
     410        return false; 
    395411    } 
    396412 
  • branches/experimental/jforms-groups/lib/jelix/tpl/jTplCompiler.class.php

    r892 r926  
    393393        } 
    394394        return $res; 
     395    } 
     396 
     397    /** 
     398     * for plugins, it says if the plugin is inside the given block 
     399     * @param string $blockName the block to search 
     400     * @param boolean $onlyUpper check only the upper block 
     401     * @return boolean  true if it is inside the block 
     402     */ 
     403    public function isInsideBlock($blockName, $onlyUpper=false) { 
     404        if($onlyUpper) 
     405            return (end($this->_blockStack) == $blockName); 
     406        for($i=count($this->_blockStack) -1; $i>=0; $i--) { 
     407            if($this->_blockStack[$i] == $blockName) 
     408                return true; 
     409        } 
     410        return false; 
    395411    } 
    396412 
  • branches/experimental/jforms-groups/lib/jelix/tpl/jTplCompiler.class.php

    r892 r926  
    393393        } 
    394394        return $res; 
     395    } 
     396 
     397    /** 
     398     * for plugins, it says if the plugin is inside the given block 
     399     * @param string $blockName the block to search 
     400     * @param boolean $onlyUpper check only the upper block 
     401     * @return boolean  true if it is inside the block 
     402     */ 
     403    public function isInsideBlock($blockName, $onlyUpper=false) { 
     404        if($onlyUpper) 
     405            return (end($this->_blockStack) == $blockName); 
     406        for($i=count($this->_blockStack) -1; $i>=0; $i--) { 
     407            if($this->_blockStack[$i] == $blockName) 
     408                return true; 
     409        } 
     410        return false; 
    395411    } 
    396412 
  • branches/experimental/jforms-groups/lib/jelix/tpl/jTplCompiler.class.php

    r892 r926  
    393393        } 
    394394        return $res; 
     395    } 
     396 
     397    /** 
     398     * for plugins, it says if the plugin is inside the given block 
     399     * @param string $blockName the block to search 
     400     * @param boolean $onlyUpper check only the upper block 
     401     * @return boolean  true if it is inside the block 
     402     */ 
     403    public function isInsideBlock($blockName, $onlyUpper=false) { 
     404        if($onlyUpper) 
     405            return (end($this->_blockStack) == $blockName); 
     406        for($i=count($this->_blockStack) -1; $i>=0; $i--) { 
     407            if($this->_blockStack[$i] == $blockName) 
     408                return true; 
     409        } 
     410        return false; 
    395411    } 
    396412 
  • branches/experimental/jforms-groups/testapp/modules/testapp/forms/sample.form.xml

    r907 r926  
    33 
    44   <hidden ref="hiddenvalue" defaultvalue="my hidden value"/> 
     5    <group ref="identity"> 
     6        <label>Your identity</label> 
    57 
    6    <input ref="nom" required="true"> 
    7       <label>Votre nom</label> 
    8    </input> 
     8        <input ref="nom" required="true"> 
     9            <label>Your name</label> 
     10        </input> 
    911 
    10    <input ref="prenom" defaultvalue="robert"> 
    11       <label>Votre prénom</label> 
    12    </input> 
     12        <input ref="prenom" defaultvalue="robert"> 
     13            <label>Your firstname</label> 
     14        </input> 
    1315 
    14    <input ref="mail" type="email"> 
    15       <label>Votre mail</label> 
    16    </input> 
     16        <radiobuttons ref="sexe" required="true"> 
     17            <label>Vous êtes </label> 
     18            <item value="h">un homme</item> 
     19            <item value="f">une femme</item> 
     20            <item value="no">je ne sais pas</item> 
     21            <alert type="required">Vous devez indiquer le sexe, même si vous ne savez pas :-)</alert> 
     22        </radiobuttons> 
     23        <input ref="mail" type="email"> 
     24            <label>Votre mail</label> 
     25        </input> 
    1726 
    18    <checkbox ref="geek"> 
    19        <label>Êtes vous un geek ?</label> 
    20        <help>Un geek est un passionné d'informatique</help> 
    21        <hint>Cochez la case si vous êtes un geek</hint> 
    22    </checkbox> 
    23  
    24    <radiobuttons ref="sexe" required="true"> 
    25       <label>Vous êtes </label> 
    26       <item value="h">un homme</item> 
    27       <item value="f">une femme</item> 
    28       <item value="no">je ne sais pas</item> 
    29       <alert type="required">Vous devez indiquer le sexe, même si vous ne savez pas :-)</alert> 
    30   </radiobuttons> 
     27        <checkbox ref="geek"> 
     28            <label>Êtes vous un geek ?</label> 
     29