mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-20 14:43:49 +00:00
Household/composition add + fixes household composition editor
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\PersonBundle\Form;
|
||||
|
||||
use Chill\MainBundle\Form\Type\ChillDateType;
|
||||
use Chill\MainBundle\Form\Type\CommentType;
|
||||
use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
|
||||
use Chill\PersonBundle\Repository\Household\HouseholdCompositionTypeRepository;
|
||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\IntegerType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
|
||||
class HouseholdCompositionType extends AbstractType
|
||||
{
|
||||
private HouseholdCompositionTypeRepository $householdCompositionTypeRepository;
|
||||
|
||||
private TranslatableStringHelperInterface $translatableStringHelper;
|
||||
|
||||
public function __construct(HouseholdCompositionTypeRepository $householdCompositionTypeRepository, TranslatableStringHelperInterface $translatableStringHelper)
|
||||
{
|
||||
$this->householdCompositionTypeRepository = $householdCompositionTypeRepository;
|
||||
$this->translatableStringHelper = $translatableStringHelper;
|
||||
}
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
$types = $this->householdCompositionTypeRepository->findAllActive();
|
||||
|
||||
$builder
|
||||
->add('householdCompositionType', EntityType::class, [
|
||||
'class' => \Chill\PersonBundle\Entity\Household\HouseholdCompositionType::class,
|
||||
'choices' => $types,
|
||||
'choice_label' => function (\Chill\PersonBundle\Entity\Household\HouseholdCompositionType $type) {
|
||||
return $this->translatableStringHelper->localize($type->getLabel());
|
||||
},
|
||||
'label' => 'household_composition.Household composition',
|
||||
])
|
||||
->add('startDate', ChillDateType::class, [
|
||||
'required' => true,
|
||||
'input' => 'datetime_immutable',
|
||||
])
|
||||
->add('numberOfChildren', IntegerType::class, [
|
||||
'required' => true,
|
||||
'label' => 'household_composition.numberOfChildren',
|
||||
])
|
||||
->add('comment', CommentType::class, [
|
||||
'required' => false,
|
||||
]);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user