1 | <?php |
||
12 | class CreateCommForm 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, $id, $parentid = null) |
|
20 | { |
||
21 | 1 | parent::__construct($di); |
|
22 | 1 | $this->aForm($id, $parentid); |
|
23 | 1 | } |
|
24 | |||
25 | |||
26 | /** |
||
27 | * Create the form. |
||
28 | * |
||
29 | */ |
||
30 | 1 | public function aForm($id, $parentid) |
|
31 | { |
||
32 | 1 | $this->form->create( |
|
33 | 1 | ["id" => __CLASS__, "legend" => "Gör ett inlägg",], |
|
34 | [ |
||
35 | 1 | "title" => ["type" => "text", "label" => "Titel","validation" => ["not_empty"]], |
|
36 | 1 | "id" => ["type" => "hidden", "value" => $id], |
|
37 | 1 | "parentid" => ["type" => "hidden", "value" => $parentid], |
|
38 | 1 | "comment" => ["type" => "textarea","label" => "Text","validation" => ["not_empty"]], |
|
39 | 1 | "submit" => ["type" => "submit", "value" => "Spara", "callback" => [$this, "callbackSubmit"]], |
|
40 | ] |
||
41 | 1 | ); |
|
42 | 1 | } |
|
43 | |||
44 | |||
45 | |||
46 | /** |
||
47 | * Callback for submit-button which should return true if it could |
||
48 | * carry out its work and false if something failed. |
||
49 | * |
||
50 | * @return boolean true if okey, false if something went wrong. |
||
51 | */ |
||
52 | public function callbackSubmit() |
||
79 | } |
||
80 |