forked from PHPShip/Formify
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
74 lines (59 loc) · 1.71 KB
/
index.php
File metadata and controls
74 lines (59 loc) · 1.71 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
<?php declare(strict_types=1);
require 'vendor/autoload.php';
use Formify\Form;
$config = [
'action' => 'action.php',
'method' => 'POST',
'enctype' => 'multipart/form-data'
];
$form = new Form($config);
$form->csrf('abc123token');
$form->field()
->name('emailAddress')
->type('email')
->placeholder('Enter your e-mail')
->style('border border-blue-100') // tailwindcss classes work here!
->value('example@gmail.com');
$fieldset = $form->fieldset()->legend('Personal Information');
$fieldset->field()->name('firstName')->type('text')->placeholder('First name');
$fieldset->field()->name('lastName')->type('text')->placeholder('Last name');
$form->field()
->name('fullName')
->type('text')
->placeholder('Enter your name')
->style('border border-blue-100')
->value('polarnix');
$form->field()->name('randomFieldTest');
$form->textarea()
->name('message')
->placeholder('Enter your message')
->rows(6)
->cols(40)
->style('border border-gray-300')
->content('Hello, world!');
$form->select()
->name('country')
->style('border border-gray-300')
->options([
'us' => 'United States',
'nl' => 'Netherlands',
'de' => 'Germany',
'fr' => 'France',
]);
$form->checkbox('interests', [
'coding' => 'Coding',
'design' => 'Design',
'music' => 'Music',
]);
$form->radio('gender', [
'male' => 'Male',
'female' => 'Female',
'other' => 'Other',
]);
$form->button('Send')
->style('bg-blue-500 text-white px-4 py-2 rounded');
// Capture the form HTML as a string using toHtml()
$formHtml = $form->toHtml();
echo $formHtml;
// render() still works — echoes directly
$form->render();