Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Custom CountryType for list only countries without territories #11439

Merged
merged 1 commit into from
Feb 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/Admin/AbstractAdherentAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
use App\Form\EventListener\CommitteeMembershipListener;
use App\Form\EventListener\RevokeManagedAreaSubscriber;
use App\Form\GenderType;
use App\Form\ReCountryType;
use App\Form\TelNumberType;
use App\FranceCities\FranceCities;
use App\History\AdministratorActionEvent;
Expand Down Expand Up @@ -73,7 +74,6 @@
use Symfony\Bundle\SecurityBundle\Security;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
use Symfony\Component\Form\Extension\Core\Type\CountryType;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\Extension\Core\Type\IntegerType;
use Symfony\Component\Form\Extension\Core\Type\NumberType;
Expand Down Expand Up @@ -272,7 +272,7 @@ protected function configureFormFields(FormMapper $form): void
->add('emailAddress', null, [
'label' => 'Adresse email',
])
->add('nationality', CountryType::class, [
->add('nationality', ReCountryType::class, [
'label' => 'Nationalité',
])
->add('phone', TelNumberType::class, [
Expand Down Expand Up @@ -311,7 +311,7 @@ protected function configureFormFields(FormMapper $form): void
->add('postAddress.additionalAddress', TextType::class, ['label' => 'Complément d\'adresse', 'required' => false])
->add('postAddress.postalCode', TextType::class, ['label' => 'Code postal'])
->add('postAddress.cityName', TextType::class, ['label' => 'Ville'])
->add('postAddress.country', CountryType::class, ['label' => 'Pays'])
->add('postAddress.country', ReCountryType::class, ['label' => 'Pays'])
->add('postAddress.latitude', NumberType::class, [
'label' => 'Latitude',
'html5' => true,
Expand Down Expand Up @@ -632,7 +632,7 @@ protected function configureDatagridFilters(DatagridMapper $filter): void
])
->add('postAddress.country', null, [
'label' => 'Pays',
'field_type' => CountryType::class,
'field_type' => ReCountryType::class,
])
->add('mailchimpStatus', ChoiceFilter::class, [
'label' => 'Abonnement email',
Expand Down
7 changes: 3 additions & 4 deletions src/Admin/CommitteeAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use App\Entity\CommitteeMembership;
use App\Entity\Geo\Zone;
use App\Form\Admin\RenaissanceAdherentAutocompleteType;
use App\Form\ReCountryType;
use Doctrine\ORM\EntityManagerInterface as ObjectManager;
use Doctrine\ORM\QueryBuilder;
use Sonata\AdminBundle\Admin\AbstractAdmin;
Expand All @@ -27,7 +28,6 @@
use Sonata\DoctrineORMAdminBundle\Filter\DateRangeFilter;
use Sonata\Form\Type\DateRangePickerType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\CountryType;
use Symfony\Component\Form\Extension\Core\Type\EmailType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\Extension\Core\Type\UrlType;
Expand Down Expand Up @@ -215,9 +215,8 @@ protected function configureFormFields(FormMapper $form): void
'required' => false,
'label' => 'Ville',
])
->add('postAddress.country', CountryType::class, [
->add('postAddress.country', ReCountryType::class, [
'required' => false,
'label' => 'Pays',
])
->end()
->end()
Expand Down Expand Up @@ -400,7 +399,7 @@ protected function configureDatagridFilters(DatagridMapper $filter): void
->add('country', CallbackFilter::class, [
'label' => 'Pays',
'show_filter' => true,
'field_type' => CountryType::class,
'field_type' => ReCountryType::class,
'callback' => function (ProxyQuery $qb, string $alias, string $field, FilterData $value) {
if (!$value->hasValue()) {
return false;
Expand Down
12 changes: 5 additions & 7 deletions src/Admin/DonationAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace App\Admin;

use App\Address\AddressInterface;
use App\Admin\Exporter\IterableCallbackDataSourceTrait;
use App\Admin\Exporter\IteratorCallbackDataSource;
use App\Admin\Filter\UtmFilter;
Expand All @@ -15,6 +14,7 @@
use App\Entity\DonationTag;
use App\Entity\Geo\Zone;
use App\Entity\PostAddress;
use App\Form\ReCountryType;
use App\Membership\Event\UserEvent;
use App\Membership\MembershipSourceEnum;
use App\Membership\UserEvents;
Expand All @@ -40,7 +40,6 @@
use Sonata\Form\Type\DateRangePickerType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\CountryType;
use Symfony\Component\Form\Extension\Core\Type\FileType;
use Symfony\Component\Form\Extension\Core\Type\NumberType as FormNumberType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
Expand Down Expand Up @@ -152,9 +151,8 @@ protected function configureFormFields(FormMapper $form): void
'btn_add' => false,
'callback' => [$this, 'prepareDestinationAutocompleteCallback'],
])
->add('nationality', CountryType::class, [
->add('nationality', ReCountryType::class, [
'label' => 'Nationalité',
'preferred_choices' => [AddressInterface::FRANCE],
])
->add('donatedAt', null, [
'label' => 'Date du don',
Expand Down Expand Up @@ -198,7 +196,7 @@ protected function configureFormFields(FormMapper $form): void
'label' => 'Ville',
'required' => true,
])
->add('postAddress.country', CountryType::class, [
->add('postAddress.country', ReCountryType::class, [
'label' => 'Pays',
'required' => true,
])
Expand Down Expand Up @@ -455,15 +453,15 @@ protected function configureDatagridFilters(DatagridMapper $filter): void
->add('nationality', ChoiceFilter::class, [
'label' => 'Nationalité',
'show_filter' => true,
'field_type' => CountryType::class,
'field_type' => ReCountryType::class,
'field_options' => [
'multiple' => true,
],
])
->add('postAddress.country', ChoiceFilter::class, [
'label' => 'Pays de résidence',
'show_filter' => true,
'field_type' => CountryType::class,
'field_type' => ReCountryType::class,
'field_options' => [
'multiple' => true,
],
Expand Down
12 changes: 4 additions & 8 deletions src/Admin/DonatorAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace App\Admin;

use App\Address\AddressInterface;
use App\Admin\Exporter\IterableCallbackDataSourceTrait;
use App\Admin\Exporter\IteratorCallbackDataSource;
use App\Donation\DonatorManager;
Expand All @@ -14,6 +13,7 @@
use App\Entity\Transaction;
use App\Form\Admin\DonatorKinshipType;
use App\Form\GenderType;
use App\Form\ReCountryType;
use App\Repository\DonationRepository;
use App\Utils\PhoneNumberUtils;
use App\Utils\PhpConfigurator;
Expand All @@ -33,7 +33,6 @@
use Sonata\Form\Type\DateRangePickerType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
use Symfony\Component\Form\Extension\Core\Type\CountryType;
use Symfony\Component\Form\Extension\Core\Type\TextType;

class DonatorAdmin extends AbstractAdmin
Expand Down Expand Up @@ -113,10 +112,7 @@ protected function configureFormFields(FormMapper $form): void
->add('city', null, [
'label' => 'Ville',
])
->add('country', CountryType::class, [
'label' => 'Pays',
'preferred_choices' => [AddressInterface::FRANCE],
])
->add('country', ReCountryType::class)
->end()
->with('Administration', ['class' => 'col-md-6'])
->add('tags', null, [
Expand Down Expand Up @@ -183,15 +179,15 @@ protected function configureDatagridFilters(DatagridMapper $filter): void
->add('donations.nationality', ChoiceFilter::class, [
'label' => 'Nationalité',
'show_filter' => true,
'field_type' => CountryType::class,
'field_type' => ReCountryType::class,
'field_options' => [
'multiple' => true,
],
])
->add('country', ChoiceFilter::class, [
'label' => 'Pays de résidence',
'show_filter' => true,
'field_type' => CountryType::class,
'field_type' => ReCountryType::class,
'field_options' => [
'multiple' => true,
],
Expand Down
5 changes: 2 additions & 3 deletions src/Admin/EventAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use App\Event\EventVisibilityEnum;
use App\Events;
use App\Form\EventCategoryType;
use App\Form\ReCountryType;
use App\Utils\PhpConfigurator;
use Sonata\AdminBundle\Datagrid\DatagridMapper;
use Sonata\AdminBundle\Datagrid\ListMapper;
Expand All @@ -24,7 +25,6 @@
use Sonata\DoctrineORMAdminBundle\Filter\DateRangeFilter;
use Sonata\Form\Type\DateRangePickerType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\CountryType;
use Symfony\Component\Form\Extension\Core\Type\EnumType;
use Symfony\Component\Form\Extension\Core\Type\NumberType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
Expand Down Expand Up @@ -199,8 +199,7 @@ protected function configureFormFields(FormMapper $form): void
'label' => 'Ville',
'required' => false,
])
->add('postAddress.country', CountryType::class, [
'label' => 'Pays',
->add('postAddress.country', ReCountryType::class, [
'required' => false,
])
->add('postAddress.latitude', NumberType::class, [
Expand Down
4 changes: 2 additions & 2 deletions src/Admin/Procuration/AbstractProcurationAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use App\Entity\ProcurationV2\AbstractProcuration;
use App\Entity\ProcurationV2\Round;
use App\Form\GenderType;
use App\Form\ReCountryType;
use App\Form\TelNumberType;
use App\Query\Utils\MultiColumnsSearchHelper;
use App\Utils\PhoneNumberUtils;
Expand All @@ -28,7 +29,6 @@
use Sonata\Form\Type\DateRangePickerType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\CountryType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Contracts\Translation\TranslatorInterface;

Expand Down Expand Up @@ -80,7 +80,7 @@ protected function configureFormFields(FormMapper $form): void
->add('postAddress.additionalAddress', TextType::class, ['label' => 'Complément d\'adresse', 'required' => false])
->add('postAddress.postalCode', TextType::class, ['label' => 'Code postal'])
->add('postAddress.cityName', TextType::class, ['label' => 'Ville'])
->add('postAddress.country', CountryType::class, ['label' => 'Pays'])
->add('postAddress.country', ReCountryType::class)
->add('joinNewsletter', CheckboxType::class, [
'label' => 'Inscription à la newsletter',
'required' => false,
Expand Down
2 changes: 1 addition & 1 deletion src/Entity/Adherent.php
Original file line number Diff line number Diff line change
Expand Up @@ -850,7 +850,7 @@ public function getCustomGender(): ?string

public function isForeignResident(): bool
{
return !\in_array(strtoupper($this->getCountry()), AddressInterface::FRENCH_CODES, true);
return AddressInterface::FRANCE !== strtoupper($this->getCountry());
}

public function isParisResident(): bool
Expand Down
5 changes: 1 addition & 4 deletions src/Form/AddressType.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
use App\FranceCities\FranceCities;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\CallbackTransformer;
use Symfony\Component\Form\Extension\Core\Type\CountryType;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
Expand Down Expand Up @@ -56,11 +55,9 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
'required' => false,
'disabled' => $options['disable_fields'],
])
->add('country', CountryType::class, [
'label' => 'Pays',
->add('country', ReCountryType::class, [
'disabled' => $options['disable_fields'],
'placeholder' => 'Sélectionner un pays',
'preferred_choices' => [AddressInterface::FRANCE],
'invalid_message' => 'common.country.invalid',
])
->add('postalCode', TextType::class, [
Expand Down
4 changes: 1 addition & 3 deletions src/Form/AdherentProfileType.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
use App\Entity\JobEnum;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\CountryType;
use Symfony\Component\Form\Extension\Core\Type\EmailType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\Extension\Core\Type\UrlType;
Expand All @@ -32,9 +31,8 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
'format_identity_case' => true,
'disabled' => $options['disabled_form'],
])
->add('nationality', CountryType::class, [
->add('nationality', ReCountryType::class, [
'placeholder' => 'Nationalité',
'preferred_choices' => [AddressInterface::FRANCE],
])
->add('emailAddress', EmailType::class)
->add('position', ActivityPositionType::class, [
Expand Down
5 changes: 2 additions & 3 deletions src/Form/Admin/Adherent/CreateRenaissanceType.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
use App\Form\AddressType;
use App\Form\BirthdateType;
use App\Form\GenderCivilityType;
use App\Form\ReCountryType;
use App\Form\TelNumberType;
use App\Renaissance\Membership\Admin\AdherentCreateCommand;
use App\Renaissance\Membership\Admin\CotisationAmountChoiceEnum;
use App\Renaissance\Membership\Admin\CotisationTypeChoiceEnum;
use App\Renaissance\Membership\Admin\MembershipTypeEnum;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\CountryType;
use Symfony\Component\Form\Extension\Core\Type\DateType;
use Symfony\Component\Form\Extension\Core\Type\EmailType;
use Symfony\Component\Form\Extension\Core\Type\NumberType;
Expand All @@ -37,8 +37,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
'format_identity_case' => true,
'disabled' => $fromCertifiedAdherent,
])
->add('nationality', CountryType::class, [
'preferred_choices' => [AddressInterface::FRANCE],
->add('nationality', ReCountryType::class, [
'disabled' => $fromCertifiedAdherent,
'invalid_message' => 'common.nationality.invalid',
])
Expand Down
4 changes: 1 addition & 3 deletions src/Form/AutocompleteAddressType.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
use App\FranceCities\FranceCities;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\CallbackTransformer;
use Symfony\Component\Form\Extension\Core\Type\CountryType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormEvent;
Expand All @@ -31,9 +30,8 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
'required' => false,
])
->add('cityName', TextType::class)
->add('country', CountryType::class, [
->add('country', ReCountryType::class, [
'placeholder' => '',
'preferred_choices' => [AddressInterface::FRANCE],
'invalid_message' => 'common.country.invalid',
])
->add('postalCode', TextType::class)
Expand Down
5 changes: 2 additions & 3 deletions src/Form/BesoinDEurope/DonationRequestType.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@

namespace App\Form\BesoinDEurope;

use App\Address\AddressInterface;
use App\Form\AutocompleteAddressType;
use App\Form\GenderCivilityType;
use App\Form\ReCountryType;
use App\Form\RequiredCheckboxType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\CountryType;
use Symfony\Component\Form\Extension\Core\Type\EmailType;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
Expand All @@ -23,7 +22,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
->add('civility', GenderCivilityType::class)
->add('firstName', TextType::class)
->add('lastName', TextType::class)
->add('nationality', CountryType::class, ['preferred_choices' => [AddressInterface::FRANCE]])
->add('nationality', ReCountryType::class)
->add('address', AutocompleteAddressType::class, ['with_additional_address' => true])
->add('autorisations', RequiredCheckboxType::class)
;
Expand Down
4 changes: 1 addition & 3 deletions src/Form/DonationRequestV2Type.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@

namespace App\Form;

use App\Address\AddressInterface;
use App\Donation\Request\DonationRequest;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\CountryType;
use Symfony\Component\Form\Extension\Core\Type\EmailType;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
Expand All @@ -30,7 +28,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
->add('firstName', TextType::class)
->add('lastName', TextType::class)
->add('emailAddress', EmailType::class)
->add('nationality', CountryType::class, ['preferred_choices' => [AddressInterface::FRANCE]])
->add('nationality', ReCountryType::class)
->add('address', AutocompleteAddressType::class, ['with_additional_address' => true])

->add('autorisations', RequiredCheckboxType::class)
Expand Down
Loading