1 | <?php |
||
12 | class CreateUserForm2 extends FormModel |
||
13 | { |
||
14 | /** |
||
15 | * Constructor injects with DI container. |
||
16 | * |
||
17 | * @param Anax\DI\DIInterface $di a service container |
||
18 | */ |
||
19 | 1 | public function __construct(DIInterface $di) |
|
20 | { |
||
21 | 1 | parent::__construct($di); |
|
22 | 1 | $this->form->create( |
|
23 | [ |
||
24 | 1 | "id" => __CLASS__, |
|
25 | 1 | "legend" => "Create user", |
|
26 | "fieldset" => true |
||
27 | 1 | ], |
|
28 | [ |
||
29 | 1 | "name" => [ |
|
30 | 1 | "type" => "text", |
|
31 | 1 | "validation" => ["not_empty"] |
|
32 | 1 | ], |
|
33 | |||
34 | "email" => [ |
||
35 | 1 | "type" => "text", |
|
36 | 1 | ], |
|
37 | |||
38 | "password" => [ |
||
39 | 1 | "type" => "password", |
|
40 | 1 | "validation" => ["not_empty"] |
|
41 | 1 | ], |
|
42 | |||
43 | "password-again" => [ |
||
44 | 1 | "type" => "password", |
|
45 | "validation" => [ |
||
46 | "match" => "password" |
||
47 | 1 | ], |
|
48 | 1 | ], |
|
49 | |||
50 | "select" => [ |
||
51 | 1 | "type" => "select", |
|
52 | 1 | "label" => "Select authority", |
|
53 | 1 | "options" => ["admin" => "admin", "user" => "user"], |
|
54 | 1 | ], |
|
55 | |||
56 | "submit" => [ |
||
57 | 1 | "type" => "submit", |
|
58 | 1 | "value" => "Skapa user", |
|
59 | 1 | "callback" => [$this, "callbackSubmit"] |
|
60 | 1 | ], |
|
61 | ] |
||
62 | 1 | ); |
|
63 | 1 | } |
|
64 | |||
65 | |||
66 | |||
67 | /** |
||
68 | * Callback for submit-button which should return true if it could |
||
69 | * carry out its work and false if something failed. |
||
70 | * |
||
71 | * @return boolean true if okey, false if something went wrong. |
||
72 | */ |
||
73 | public function callbackSubmit() |
||
110 | } |
||
111 |