rimie1
Invité n'ayant pas de compte PHPfrance
08 mai 2011, 03:01
merci Ryle et xTG, je vais la changer.
je voudrais ajouter un truc de plus, j'ai voulu mettre la meme chose pour un autre champs (addInput), mais ca marche pas, je l'ai resume en var_dump afin de voir les valeurs retournees, pour la balise form: ca marche, il me retourne les valeurs dans le tableau, par contre la balise input, me retourne rien, c'est quoi le probleme exactement?
<?php
class Formulaire {
public final function __construct($name, $method='', $action='', $formOptions=array(), $enctype='') {
$this->formOptions = $formOptions;
$formOptionsArray = array(
"autocomplete" => array('on', 'off'),
"target" => array('_self', '_blank', '_parent', '_top'),
"novalidate" => array("novalidate"),
"DISABLED" => array(""),
);
$this->formOptionsArray = $formOptionsArray;
$formOptions = trim($formOptions);
// fonctions des Inputs
public final function addInput($type, $name='', $value='', $inputOptions=array()){
$this->InputOptions = $InputOptions; // autres options des inputs
$InputOptionsArray = array(
'id' => array(''),
'class' => array(''),
'checked' => array('checked'),
'autocpmplete' => array('on', 'off'),
);
$this->InputOptionsArray = $InputOptionsArray;
$InputOptions = trim($InputOptions);
} // end addInput
// fonction de creation de formulaire
function createForm(){
echo 'this form options: '.var_dump($this->formOptions).'<br>';
echo 'this input options: '.var_dump($this->InputOptions).'<br>';
} // end function createForm
} // end class
// on affiche le formulaire
$frm1 = new Formulaire('monForm1', '', '', array('autocomplet' => 'on', 'target' => '_self', 'DISABLED' => '','novalidate' => 'novalidate'));
$frm1->addInput('text', 'nomText1', 'valTxt', array('id' => 'MyText2', 'class' => 'maClass')); // text
echo $frm1->createForm();
?>
Merci