-
Notifications
You must be signed in to change notification settings - Fork 126
Expand file tree
/
Copy pathCreateTopicForm.php
More file actions
73 lines (64 loc) · 1.74 KB
/
Copy pathCreateTopicForm.php
File metadata and controls
73 lines (64 loc) · 1.74 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
62
63
64
65
66
67
68
69
70
71
72
73
<?php
namespace Craue\FormFlowBundle\Tests\IntegrationTestBundle\Form;
use Craue\FormFlowBundle\Tests\IntegrationTestBundle\Entity\Topic;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
/**
* @author Christian Raue <christian.raue@gmail.com>
* @copyright 2011-2015 Christian Raue
* @license http://opensource.org/licenses/mit-license.php MIT License
*/
class CreateTopicForm extends AbstractType {
/**
* {@inheritDoc}
*/
public function buildForm(FormBuilderInterface $builder, array $options) {
$isBugReport = $options['isBugReport'];
switch ($options['flow_step']) {
case 1:
$builder->add('title');
$builder->add('description', null, array(
'required' => false,
));
$choices = Topic::getValidCategories();
$builder->add('category', 'choice', array(
'choices' => array_combine($choices, $choices),
'empty_value' => '',
));
break;
case 2:
$builder->add('comment', 'textarea', array(
'required' => false,
));
break;
case 3:
if ($isBugReport) {
$builder->add('details', 'textarea');
}
break;
}
}
/**
* {@inheritDoc}
*/
public function configureOptions(OptionsResolver $resolver) {
$resolver->setDefaults(array(
'isBugReport' => false,
));
}
/**
* {@inheritDoc}
*/
// TODO remove as soon as Symfony >= 2.7 is required
public function setDefaultOptions(OptionsResolverInterface $resolver) {
$this->configureOptions($resolver);
}
/**
* {@inheritDoc}
*/
public function getName() {
return 'createTopic';
}
}