-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathForm.php
More file actions
55 lines (42 loc) · 2.03 KB
/
Form.php
File metadata and controls
55 lines (42 loc) · 2.03 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
<?php
namespace NGFramer\NGFramerPHPHTMLBuilder;
final class Form
{
public static function open(string $action, string $method): string
{
return "<form action='$action' method='$method'>";
}
public static function text(string $name='', string $placeholder='', string $value='', string $error='', string $id='', string $class=''): string
{
return "<input type='text' id='$id' class='$class' name='$name' placeholder='$placeholder' value='$value'> <br> $error";
}
public static function password(string $name='', string $placeholder='', string $value='', string $error='', string $id='', string $class=''): string
{
return "<input type='password' id='$id' class='$class' name='$name' placeholder='$placeholder' value='$value'>";
}
public static function submit(string $name='', string $placeholder='', string $value='', string $id='', string $class='', bool $disabled=false): string
{
if ($disabled){
return "<input type='submit' id='$id' class='$class' name='$name' placeholder='$placeholder' value='$value' disabled>";
}
return "<input type='submit' id='$id' class='$class' name='$name' placeholder='$placeholder' value='$value'>";
}
public static function radio(string $name='', string $value = '', bool $checked = false, bool $disabled = false, string $id = '', string $class=''): string
{
if ($checked){
if ($disabled){
return "<input type='checkbox' name='$name' value='$value' checked id='$id' class='$class'disabled>";
}
return "<input type='checkbox' name='$name' value='$value' id='$id' class='$class'disabled>";
}else{
if ($disabled){
return "<input type='checkbox' name='$name' value='$value' id='$id' class='$class'disabled>";
}
return "<input type='checkbox' name='$name' value='$value' id='$id' class='$class'>";
}
}
public static function close(): string
{
return "</form>";
}
}