-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathmultiple.php
More file actions
43 lines (36 loc) · 1.08 KB
/
multiple.php
File metadata and controls
43 lines (36 loc) · 1.08 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
<?php
class Film
{
public $name;
public $actors;
}
include(__DIR__ . '/../vendor/autoload.php');
$form = new Gregwar\Formidable\Form('<form method="post">
<h2>Film</h2>
Film name:
<input type="text" name="film_name" mapping="name" />
<hr />
<h2>Actors</h2>
<multiple name="actors" mapping="actors" min-entries="2">
<fieldset>
First name: <input name="first_name" mapping="firstName" /><br />
Last name: <input name="last_name" mapping="lastName" /><br />
Age: <input type="int" name="age" min="7" mapping="age" optional />
Gender:
<select mapping="gender" name="gender">
<option value="m">Male</option>
<option value="f">Female</option>
</select>
</fieldset>
</multiple>
<input type="submit" />
</form>', array(), true);
$form->handle(function() use ($form) {
var_dump($form->getData(new Film));
}, function($errors) {
echo "Errors:<br />";
foreach ($errors as $error) {
echo "* $error<br/>";
}
});
echo $form;