location admin: improve admin crud for location

This commit is contained in:
nobohan
2021-10-22 10:01:24 +02:00
parent e9322e61d4
commit e24fd8aff0
6 changed files with 54 additions and 19 deletions

View File

@@ -2,7 +2,6 @@
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;
@@ -10,15 +9,18 @@ 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;
use Symfony\Component\OptionsResolver\OptionsResolver;
final class LocationType extends AbstractType
final class LocationFormType extends AbstractType
{
// private TranslatableStringHelper $translatableStringHelper;
// public function __construct(
// TranslatableStringHelper $translatableStringHelper
// ) {
// /**
// * @param TranslatableStringHelper $translatableStringHelper
// */
// public function __construct(TranslatableStringHelper $translatableStringHelper)
// {
// $this->translatableStringHelper = $translatableStringHelper;
// }
@@ -33,7 +35,7 @@ final class LocationType extends AbstractType
->add('locationType', EntityType::class, [
'class' => EntityLocationType::class,
'choice_label' => function (EntityLocationType $entity) {
//return $this->translatableStringHelper->localize($entity->getTitle());
//return $this->translatableStringHelper->localize($entity->getTitle()); //TODO not working. Cannot pass smthg in the constructor
return $entity->getTitle()['fr'];
},
])
@@ -44,4 +46,24 @@ final class LocationType extends AbstractType
'mapped' => false,
]);
}
/**
* @param OptionsResolverInterface $resolver
*/
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(array(
'data_class' => 'Chill\MainBundle\Entity\Location'
));
}
/**
* @return string
*/
public function getBlockPrefix()
{
return 'chill_mainbundle_location';
}
}