1 | 2 | simandl | <?php |
2 | | | |
3 | | | namespace Phem\Controllers; |
4 | | | |
5 | | | use Phem\Controllers\SimpleViewController; |
6 | | | use Phem\Libraries\Forms\AnnotationFormBuilder; |
7 | | | use Srovnavac\Libraries\Environment\EnvironmentManager; |
8 | | | |
9 | | | /** |
10 | | | * Administration |
11 | | | * |
12 | | | * @author Jakub PetrĹžĂlka <petrzilka@czweb.net> |
13 | | | */ |
14 | | | class FormController extends SimpleViewController |
15 | | | { |
16 | | | |
17 | | | function __construct() |
18 | | | { |
19 | | | parent::__construct(); |
20 | | | $classPathArray = explode("\\", get_class($this)); |
21 | | | $classShortName = end($classPathArray); |
22 | | | $controllerName = str_replace("Controller", "", $classShortName); |
23 | | | |
24 | | | $this->getModel()->set('updateFormUrl', EnvironmentManager::getLinkBuilder()->link(array("controller" => $controllerName, "task" => "updateForm"))); |
25 | | | } |
26 | | | |
27 | | | public function updateForm() |
28 | | | { |
29 | | | $data = EnvironmentManager::getSubmittedFormObject(); |
30 | | | $ab = new AnnotationFormBuilder(); |
31 | | | $form = $ab->buildForm(get_class($data), $data); |
32 | | | $this->model->put("form", $form); |
33 | | | $this->template = "@Phem/simpleForm.twig"; |
34 | | | } |
35 | | | |
36 | | | } |