-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRoutineFormType.php
More file actions
57 lines (53 loc) · 1.44 KB
/
RoutineFormType.php
File metadata and controls
57 lines (53 loc) · 1.44 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
<?php
namespace SyncEngine\Form;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use SyncEngine\Entity\Routine;
use SyncEngine\Form\Type\JsonType;
use SyncEngine\Model\RoutineModel;
class RoutineFormType extends AbstractType
{
public function buildForm( FormBuilderInterface $builder, array $options ): void
{
$builder
->add( 'name', TextType::class, [
'required' => true,
'row_attr' => [
'col-row-group' => 'name-desc',
'col-class' => 'col-12 col-lg-6',
'class' => 'form-floating mb-3',
],
] )
->add( 'description', TextType::class, [
'required' => false,
'row_attr' => [
'col-row-group' => 'name-desc',
'col-class' => 'col-12 col-lg-6',
'class' => 'form-floating mb-3',
],
] )
->add( 'config', JsonType::class, [
'row_attr' => [
'class' => 'form-floating mb-3',
],
'attr' => [
'data-controller' => 'react',
'data-type' => 'config',
'data-args' => json_encode( [
'fields' => RoutineModel::create()->getFields(),
'tags' => [
'context' => [ 'routine' => '_entity' ],
],
] ),
],
] );
}
public function configureOptions( OptionsResolver $resolver ): void
{
$resolver->setDefaults( [
'data_class' => Routine::class,
] );
}
}