-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathTaskFormView.php
More file actions
61 lines (48 loc) · 1.77 KB
/
TaskFormView.php
File metadata and controls
61 lines (48 loc) · 1.77 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
<?php
namespace App\view;
use App\view\AbstractView;
use App\view\gui\Form;
use App\view\gui\Input;
use App\view\gui\Label;
/**
* View de criação e edição de tarefas
*/
class TaskFormView extends AbstractView {
private function createForm( $taskName = null , $taskDescription = null , $taskStatus = null ) {
$taskNameInput = new Input( 'taskName' );
$taskDescriptionInput = new Input( 'taskDescription' );
$taskStatusInput = new Input( 'taskStatus' );
if ( !is_null( $taskName ) ) {
$taskNameInput->addAttribute( 'value' , $taskName );
}
if ( !is_null( $taskDescription ) ) {
$taskDescriptionInput->addAttribute( 'value' , $taskDescription );
}
if ( !is_null( $taskStatus ) ) {
$taskStatusInput->addAttribute( 'value' , $taskStatus );
}
$form = $this->applicationPanel->addChild( new Form( '?action=save' ) );
$form->addChild( new Label( 'Nome:' ) )->addAttribute( 'for' , 'taskName' );
$form->addChild( $taskNameInput );
$form->addChild( new Label( 'Descrição:' ) )->addAttribute( 'for' , 'taskDescription' );
$form->addChild( $taskDescriptionInput );
$form->addChild( new Label( 'Situação:' ) )->addAttribute( 'for' , 'taskStatus' );
$form->addChild( $taskStatusInput );
$form->addChild( new Input( 'Enviar' , 'submit' ) );
return $form;
}
/**
* Cria o formulário de criação de uma tarefa
*/
public function createTaskCreationForm() {
$this->createForm();
}
/**
* Cria o formulário de edição de uma tarefa.
*/
public function createTaskEditionForm() {
$task = $this->taskRepository->getCurrentTask();
$form = $this->createForm( $task->getTaskName() , $task->getTaskDescription() , $task->getTaskStatus() );
$form->addChild( new Input( 'idTask' , 'hidden' ) )->addAttribute( 'value' , $task->getIdTask() );
}
}