location admin: admin crud for location

This commit is contained in:
nobohan
2021-10-21 21:39:32 +02:00
parent 92843677f9
commit e9322e61d4
8 changed files with 190 additions and 1 deletions

View File

@@ -0,0 +1,47 @@
<?php
namespace Chill\MainBundle\Form;
use Chill\MainBundle\Entity\Address;
use Chill\MainBundle\Entity\LocationType as EntityLocationType;
use Chill\MainBundle\Form\Type\PickAddressType;
use Chill\MainBundle\Templating\TranslatableStringHelper;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
final class LocationType extends AbstractType
{
// private TranslatableStringHelper $translatableStringHelper;
// public function __construct(
// TranslatableStringHelper $translatableStringHelper
// ) {
// $this->translatableStringHelper = $translatableStringHelper;
// }
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('name', TextType::class)
->add('phonenumber1', TextType::class, ['required' => false])
->add('phonenumber2', TextType::class, ['required' => false])
->add('email', TextType::class, ['required' => false])
->add('locationType', EntityType::class, [
'class' => EntityLocationType::class,
'choice_label' => function (EntityLocationType $entity) {
//return $this->translatableStringHelper->localize($entity->getTitle());
return $entity->getTitle()['fr'];
},
])
->add('address', PickAddressType::class, [
'label' => 'Address',
'use_valid_from' => false,
'use_valid_to' => false,
'mapped' => false,
]);
}
}