mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-07-03 07:26:12 +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\AsideActivity;
|
||||||
use Chill\AsideActivityBundle\Entity\AsideActivityCategory;
|
use Chill\AsideActivityBundle\Entity\AsideActivityCategory;
|
||||||
use Chill\AsideActivityBundle\Form\Type\TranslatableAsideActivityCategory;
|
|
||||||
use Chill\MainBundle\Entity\User;
|
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\Bridge\Doctrine\Form\Type\EntityType;
|
||||||
use Symfony\Component\Form\AbstractType;
|
use Symfony\Component\Form\AbstractType;
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
@ -13,21 +14,28 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
|
|||||||
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
|
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){
|
public function __construct (TranslatableStringHelper $translatableStringHelper){
|
||||||
$this->timeChoices = $timeChoices;
|
// $this->timeChoices = $timeChoices;
|
||||||
|
$this->translatableStringHelper = $translatableStringHelper;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||||
{
|
{
|
||||||
$timeChoices = [];
|
// $timeChoices = [];
|
||||||
$durationTimeOptions = [
|
|
||||||
'choices' => $timeChoices,
|
// foreach ($this->timeChoices as $e) {
|
||||||
'placeholder' => 'Choose the duration',
|
// $timeChoices[$e['label']] = $e['seconds'];
|
||||||
];
|
// }
|
||||||
|
|
||||||
|
// $durationTimeOptions = [
|
||||||
|
// 'choices' => $timeChoices,
|
||||||
|
// 'placeholder' => 'Choose the duration',
|
||||||
|
// ];
|
||||||
|
|
||||||
$builder
|
$builder
|
||||||
->add('agent', EntityType::class,
|
->add('agent', EntityType::class,
|
||||||
@ -39,16 +47,29 @@ class AsideActivityFormType extends AbstractType
|
|||||||
'placeholder' => 'Choose the agent for whom this activity is created',
|
'placeholder' => 'Choose the agent for whom this activity is created',
|
||||||
'choice_label' => 'username'
|
'choice_label' => 'username'
|
||||||
])
|
])
|
||||||
// ->add('category', TranslatableAsideActivityCategory::class)
|
->add('date', ChillDateType::class,
|
||||||
// ->add('type', EntityType::class,
|
[
|
||||||
// [
|
'label' => 'date',
|
||||||
// 'label' => 'Type',
|
'data' => new \DateTime(),
|
||||||
// 'required' => true,
|
//SETTING RANGE ONLY POSSIBLE WITH WIDGET 'CHOICE' AND NOT 'SINGLE_TEXT'?
|
||||||
// 'class' => AsideActivityCategory::class,
|
// 'widget' => 'choice',
|
||||||
// 'placeholder' => 'Choissisez le type d\'activité',
|
// 'years' => range(2020, date('Y')),
|
||||||
// 'choice_label' => 'title'
|
// 'months' => range(1, date('m')),
|
||||||
// ])
|
// 'days' => range(1, date('d')),
|
||||||
->add('durationTime', ChoiceType::class, $durationTimeOptions)
|
'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, [
|
->add('note', TextareaType::class, [
|
||||||
'label' => 'Note',
|
'label' => 'Note',
|
||||||
'required' => false,
|
'required' => false,
|
||||||
@ -64,6 +85,6 @@ class AsideActivityFormType extends AbstractType
|
|||||||
|
|
||||||
public function getBlockPrefix(): string
|
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