Household/composition add + fixes household composition editor

This commit is contained in:
2022-01-24 10:59:00 +00:00
parent 2b47868d88
commit 53b3f98bba
35 changed files with 1489 additions and 63 deletions

View File

@@ -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,
]);
}
}