mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-07-02 23:16:13 +00:00
date field added and activity type field. Form listed as service in services.yaml
asideactivity form added as service to inject necessary arguments
This commit is contained in:
parent
d67b99b269
commit
8649d49d98
@ -4,8 +4,9 @@ namespace Chill\AsideActivityBundle\Form;
|
||||
|
||||
use Chill\AsideActivityBundle\Entity\AsideActivity;
|
||||
use Chill\AsideActivityBundle\Entity\AsideActivityCategory;
|
||||
use Chill\AsideActivityBundle\Form\Type\TranslatableAsideActivityCategory;
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use Chill\MainBundle\Form\Type\ChillDateType;
|
||||
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
@ -13,21 +14,28 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
|
||||
|
||||
|
||||
class AsideActivityFormType extends AbstractType
|
||||
final class AsideActivityFormType extends AbstractType
|
||||
{
|
||||
protected array $timeChoices;
|
||||
// protected array $timeChoices;
|
||||
private TranslatableStringHelper $translatableStringHelper;
|
||||
|
||||
public function __construct (array $timeChoices){
|
||||
$this->timeChoices = $timeChoices;
|
||||
public function __construct (TranslatableStringHelper $translatableStringHelper){
|
||||
// $this->timeChoices = $timeChoices;
|
||||
$this->translatableStringHelper = $translatableStringHelper;
|
||||
}
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
$timeChoices = [];
|
||||
$durationTimeOptions = [
|
||||
'choices' => $timeChoices,
|
||||
'placeholder' => 'Choose the duration',
|
||||
];
|
||||
// $timeChoices = [];
|
||||
|
||||
// foreach ($this->timeChoices as $e) {
|
||||
// $timeChoices[$e['label']] = $e['seconds'];
|
||||
// }
|
||||
|
||||
// $durationTimeOptions = [
|
||||
// 'choices' => $timeChoices,
|
||||
// 'placeholder' => 'Choose the duration',
|
||||
// ];
|
||||
|
||||
$builder
|
||||
->add('agent', EntityType::class,
|
||||
@ -39,16 +47,29 @@ class AsideActivityFormType extends AbstractType
|
||||
'placeholder' => 'Choose the agent for whom this activity is created',
|
||||
'choice_label' => 'username'
|
||||
])
|
||||
// ->add('category', TranslatableAsideActivityCategory::class)
|
||||
// ->add('type', EntityType::class,
|
||||
// [
|
||||
// 'label' => 'Type',
|
||||
// 'required' => true,
|
||||
// 'class' => AsideActivityCategory::class,
|
||||
// 'placeholder' => 'Choissisez le type d\'activité',
|
||||
// 'choice_label' => 'title'
|
||||
// ])
|
||||
->add('durationTime', ChoiceType::class, $durationTimeOptions)
|
||||
->add('date', ChillDateType::class,
|
||||
[
|
||||
'label' => 'date',
|
||||
'data' => new \DateTime(),
|
||||
//SETTING RANGE ONLY POSSIBLE WITH WIDGET 'CHOICE' AND NOT 'SINGLE_TEXT'?
|
||||
// 'widget' => 'choice',
|
||||
// 'years' => range(2020, date('Y')),
|
||||
// 'months' => range(1, date('m')),
|
||||
// 'days' => range(1, date('d')),
|
||||
'required' => true
|
||||
])
|
||||
->add('type', EntityType::class,
|
||||
[
|
||||
'label' => 'Type',
|
||||
'required' => true,
|
||||
'class' => AsideActivityCategory::class,
|
||||
'placeholder' => 'Choose the activity category',
|
||||
// 'choice_label' => 'title[""]'
|
||||
'choice_label' => function (AsideActivityCategory $asideActivityCategory) {
|
||||
return $this->translatableStringHelper->localize($asideActivityCategory->getTitle());
|
||||
},
|
||||
])
|
||||
// ->add('durationTime', ChoiceType::class, $durationTimeOptions)
|
||||
->add('note', TextareaType::class, [
|
||||
'label' => 'Note',
|
||||
'required' => false,
|
||||
@ -64,6 +85,6 @@ class AsideActivityFormType extends AbstractType
|
||||
|
||||
public function getBlockPrefix(): string
|
||||
{
|
||||
return 'chill_activitybundle_activity';
|
||||
return 'chill_asideactivitybundle_asideactivity';
|
||||
}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
services:
|
||||
chill.asideactivity.form.type.asideactivity:
|
||||
class: Chill\AsideActivityBundle\Form\AsideActivityFormType
|
||||
arguments:
|
||||
# - "@doctrine.orm.entity_manager"
|
||||
- "@chill.main.helper.translatable_string"
|
||||
# - "%chill_activity.form.time_duration%"
|
||||
tags:
|
||||
- { name: form.type, alias: chill_asideactivitybundle_asideactivity }
|
Loading…
x
Reference in New Issue
Block a user