Fix and Enhancements

This commit is contained in:
Xbird
2022-04-26 19:17:57 +00:00
parent 200c6ac256
commit 72123b8782
22 changed files with 173 additions and 143 deletions

View File

@@ -3,6 +3,8 @@
namespace App\Form;
use App\Entity\Bracelet;
use App\Form\DocumentType;
use App\Form\Type\DateTimeVisionType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
@@ -12,7 +14,7 @@ class BraceletType extends DocumentType
{
parent::buildForm($builder, $options);
$builder
->add('removingDate', null, ['label' => 'form_label_removing_date'])
->add('removingDate', DateTimeVisionType::class, ['label' => 'form_label_removing_date'])
;
}

View File

@@ -5,6 +5,7 @@ namespace App\Form;
use App\Entity\Jail;
use App\Form\DocumentType;
use App\Form\Type\ContentType;
use App\Form\Type\DateTimeVisionType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
@@ -16,8 +17,16 @@ class JailType extends DocumentType
parent::buildForm($builder, $options);
$builder
->add('arrestedAt', null, ['label' => 'form_label_arrested_at', 'help' => 'form_help_arrested_at'])
->add('jailedAt', null, ['label' => 'form_label_jailed_at', 'help' => 'form_help_jailed_at'])
->add(
'arrestedAt',
DateTimeVisionType::class,
['label' => 'form_label_arrested_at', 'help' => 'form_help_arrested_at']
)
->add(
'jailedAt',
DateTimeVisionType::class,
['label' => 'form_label_jailed_at', 'help' => 'form_help_jailed_at']
)
->add('lawyer', CheckboxType::class, ['label' => 'form_label_asked_for_lawyer', 'required' => false])
->add('medic', CheckboxType::class, ['label' => 'form_label_asked_for_medic', 'required' => false])
->add('content', ContentType::class)

View File

@@ -5,6 +5,7 @@ namespace App\Form;
use App\Form\DocumentType;
use App\Form\Type\VehicleType;
use App\Entity\LicenceWithdrawal;
use App\Form\Type\DateTimeVisionType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
@@ -18,7 +19,7 @@ class LicenceWithdrawalType extends DocumentType
$builder
->add('type', VehicleType::class)
->add('until', null, ['label' => 'form_label_until', 'help' => 'form_help_until'])
->add('until', DateTimeVisionType::class, ['label' => 'form_label_until', 'help' => 'form_help_until'])
;
}

View File

@@ -1,58 +0,0 @@
<?php
namespace App\Form;
use App\Entity\Document;
use App\Entity\User;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
class TestType extends AbstractType
{
private TokenStorageInterface $TokenStorage;
public function __construct(TokenStorageInterface $TokenStorage)
{
$this->TokenStorage = $TokenStorage;
}
public function buildForm(FormBuilderInterface $builder, array $options): void
{
/**
* @var User $user
*/
$User = $this->TokenStorage->getToken()->getUser();
$builder
->add('title', null, [
'label' => 'form_label_title',
'priority' => 999
]);
$builder
->add(
'allowShare',
null,
[
'priority' => -900,
'label' => 'form_label_allowShare'
]
)
->add('submit', SubmitType::class, [
'label' => 'form_button_submit',
'priority' => -900,
'attr' => ['class' => 'btn-primary'],
])
;
}
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'data_class' => Document::class,
]);
}
}

View File

@@ -0,0 +1,23 @@
<?php
namespace App\Form\Type;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Form\Extension\Core\Type\DateTimeType;
class DateTimeVisionType extends AbstractType
{
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'view_timezone' => array_key_exists('TZ', $_ENV) ? $_ENV['TZ'] : false
]);
}
public function getParent(): string
{
return DateTimeType::class;
}
}