Repository navigation
Expand file tree
/
Copy pathformClass2.php
More file actions
79 lines (67 loc) · 2.05 KB
/
Copy pathformClass2.php
File metadata and controls
79 lines (67 loc) · 2.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<?php
/**
* Created by PhpStorm.
* User: Manu
* Date: 16/01/2018
* Time: 17:51
*/
trait Form
{
public function formDebut($method, $action)
{
echo '<form action=\'' . $action . '\' method = \'' . $method . '\'>' . '<br/>';
}
public function label($forLabel, $contentLabel)
{
echo '<label for=\'' . $forLabel . '\'>' . $contentLabel . '</label>'. '<br/>';
}
public function selectDebut($nameSelect)
{
echo '<select name=\'' . $nameSelect . '\'>'. '<br/>';
}
public function selectOption($optionSelect, $contentOption)
{
echo '<option value=\"' . $optionSelect . '\">' . $contentOption . '</option>'. '<br/>';
}
public function textarea($nameTextarea, $contenTextarea)
{
echo '<br/>'.'<textarea name=\'' . $nameTextarea . '\'>' . $contenTextarea . '</textarea>'.'<br/>';
}
public function formFin()
{
echo '</form>';
}
/**
* @param $inpuType
* @param $inputName
* @param $inputValue Celui ci doit etre mis pour le submit
* @return string
*/
public function input($inpuType, $inputName, $inputValue)
{
if ($inpuType=='submit') {
echo '<input type=\'' . $inpuType . '\' name =\'' . $inputName . '\' value=\'' . $inputValue . '\'>' . '<br/>';
}
else {
echo '<input type=\''.$inpuType.'\' name=\''.$inputName.'\' >'.'<br/>';
}
}
}
class Formulaire
{
use Form;
}
$utilisateur=new Formulaire;
$utilisateur->formDebut('POST','index.php');
$utilisateur->label('noms','Noms :');
$utilisateur->input('text','noms','');
$utilisateur->label('choir','choir');
$utilisateur->input('text','choir','');
$utilisateur->selectDebut('cars');
$utilisateur->selectOption('volvo','Volvo');
$utilisateur->selectOption('bmw','Bmw');
$utilisateur->selectOption('toyota','Toyota');
$textearea='Tout ceci mechappel jaimerais bien quee tout sosi e place';
$utilisateur->textarea('Commentaires',$textearea);
$utilisateur->input('submit','submit','Envoyer');
$utilisateur->formFin();