developer.jelix.org is not used any more and exists only for history. Post new tickets on the Github account.
developer.jelix.org n'est plus utilisée, et existe uniquement pour son historique. Postez les nouveaux tickets sur le compte github.

Ticket #728: 728-jForms-addControlBefore.diff

File 728-jForms-addControlBefore.diff, 2.1 KB (added by Julien, 13 years ago)
  • lib/jelix/forms/jFormsBase.class.php

     
    55* @author      Laurent Jouanneau
    66* @contributor Dominique Papin
    77* @contributor Bastien Jaillot
    8 * @contributor Christophe Thiriot
     8* @contributor Christophe Thiriot, Julien Issler
    99* @copyright   2006-2008 Laurent Jouanneau, 2007 Dominique Papin, 2008 Bastien Jaillot
     10* @copyright   2008 Julien Issler
    1011* @link        http://www.jelix.org
    1112* @licence     http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public Licence, see LICENCE file
    1213*/
     
    635636
    636637    /**
    637638    * add a control to the form
    638     * @param $control jFormsControl
     639    * @param jFormsControl $control the control to add
    639640    */
    640641    public function addControl($control){
    641642        $this->rootControls [$control->ref] = $control;
     
    647648        }
    648649    }
    649650
     651    /**
     652     * add a control to the form, before the specified control
     653     * @param jFormsControl $control the control to add
     654     * @param string $ref The ref of the control the new control should be inserted before
     655     */
     656    public function addControlBefore($control, $ref){
     657        if(isset($this->rootControls[$ref])){
     658            $controls = array();
     659            foreach($this->rootControls as $k=>$c){
     660                if($k == $ref)
     661                    $controls[$control->ref] = null;
     662                $controls[$k] = $c;
     663            }
     664            $this->rootControls = $controls;
     665        }
     666        $this->addControl($control);
     667    }
    650668
     669
    651670    function removeControl($name) {
    652671        if(!isset($this->rootControls [$name]))
    653672            return;
     
    665684
    666685    /**
    667686    * declare a child control to the form. The given control should be a child of an other control
    668     * @param $control jFormsControl
     687    * @param jFormsControl $control
    669688    */
    670689    public function addChildControl($control){
    671690        $this->controls [$control->ref] = $control;
     
    693712            }
    694713        }
    695714    }
    696 }
     715}
     716 No newline at end of file