src/Form/UserType.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Form;
  3. use App\Entity\User;
  4. use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
  5. use Symfony\Component\Form\AbstractType;
  6. use Symfony\Component\Form\FormBuilderInterface;
  7. use Symfony\Component\OptionsResolver\OptionsResolver;
  8. use Symfony\Component\Form\Extension\Core\Type\TextType;
  9. use Symfony\Component\Form\Extension\Core\Type\EmailType;
  10. class UserType extends AbstractType
  11. {
  12.     public function buildForm(FormBuilderInterface $builder, array $options): void
  13.     {
  14.         $builder
  15.             ->add('nom'null, [
  16.                 'label' => 'Name'// Use the translation key
  17.             ])
  18.             ->add('email'EmailType::class, [
  19.                 'label' => 'Email',
  20.                 'required' => true
  21.             ])
  22.             ->add('password')
  23.             ->add('username'TextType::class, [
  24.                 "attr" => [
  25.                     "minlength" => 6,
  26.                     "maxlength" => 10,
  27.                 ],
  28.             ])
  29.             ->add('country'ChoiceType::class, [
  30.                 "label" => "Country",
  31.                 'choices' => [
  32.                     "Afghanistan" => "Afghanistan",
  33.                     "Albania" => "Albania",
  34.                     "Algeria" => "Algeria",
  35.                     "Andorra" => "Andorra",
  36.                     "Angola" => "Angola",
  37.                     "Antigua And Barbuda" => "Antigua And Barbuda",
  38.                     "Argentina" => "Argentina",
  39.                     "Armenia" => "Armenia",
  40.                     "Australia" => "Australia",
  41.                     "Austria" => "Austria",
  42.                     "Azerbaijan" => "Azerbaijan",
  43.                     "Bahrain" => "Bahrain",
  44.                     "Bangladesh" => "Bangladesh",
  45.                     "Barbados" => "Barbados",
  46.                     "Belarus" => "Belarus",
  47.                     "Belgium" => "Belgium",
  48.                     "Belize" => "Belize",
  49.                     "Benin" => "Benin",
  50.                     "Bhutan" => "Bhutan",
  51.                     "Bolivia" => "Bolivia",
  52.                     "Bonaire, Sint Eustatius and Saba" => "Bonaire, Sint Eustatius and Saba",
  53.                     "Bosnia and Herzegovina" => "Bosnia and Herzegovina",
  54.                     "Botswana" => "Botswana",
  55.                     "Brazil" => "Brazil",
  56.                     "Brunei" => "Brunei",
  57.                     "Bulgaria" => "Bulgaria",
  58.                     "Burkina Faso" => "Burkina Faso",
  59.                     "Burundi" => "Burundi",
  60.                     "Cambodia" => "Cambodia",
  61.                     "Cameroon" => "Cameroon",
  62.                     "Canada" => "Canada",
  63.                     "Cape Verde" => "Cape Verde",
  64.                     "Central African Republic" => "Central African Republic",
  65.                     "Chad" => "Chad",
  66.                     "Chile" => "Chile",
  67.                     "China" => "China",
  68.                     "Colombia" => "Colombia",
  69.                     "Comoros" => "Comoros",
  70.                     "Congo" => "Congo",
  71.                     "Costa Rica" => "Costa Rica",
  72.                     "Cote D'Ivoire (Ivory Coast)" => "Cote D'Ivoire (Ivory Coast)",
  73.                     "Croatia" => "Croatia",
  74.                     "Cuba" => "Cuba",
  75.                     "Cyprus" => "Cyprus",
  76.                     "Czech Republic" => "Czech Republic",
  77.                     "Democratic Republic of the Congo" => "Democratic Republic of the Congo",
  78.                     "Denmark" => "Denmark",
  79.                     "Djibouti" => "Djibouti",
  80.                     "Dominica" => "Dominica",
  81.                     "Dominican Republic" => "Dominican Republic",
  82.                     "East Timor" => "East Timor",
  83.                     "Ecuador" => "Ecuador",
  84.                     "Egypt" => "Egypt",
  85.                     "El Salvador" => "El Salvador",
  86.                     "Equatorial Guinea" => "Equatorial Guinea",
  87.                     "Eritrea" => "Eritrea",
  88.                     "Estonia" => "Estonia",
  89.                     "Ethiopia" => "Ethiopia",
  90.                     "Fiji Islands" => "Fiji Islands",
  91.                     "Finland" => "Finland",
  92.                     "France" => "France",
  93.                     "Gabon" => "Gabon",
  94.                     "Gambia The" => "Gambia The",
  95.                     "Georgia" => "Georgia",
  96.                     "Germany" => "Germany",
  97.                     "Ghana" => "Ghana",
  98.                     "Greece" => "Greece",
  99.                     "Grenada" => "Grenada",
  100.                     "Guatemala" => "Guatemala",
  101.                     "Guinea" => "Guinea",
  102.                     "Guinea-Bissau" => "Guinea-Bissau",
  103.                     "Guyana" => "Guyana",
  104.                     "Haiti" => "Haiti",
  105.                     "Honduras" => "Honduras",
  106.                     "Hungary" => "Hungary",
  107.                     "Iceland" => "Iceland",
  108.                     "India" => "India",
  109.                     "Indonesia" => "Indonesia",
  110.                     "Iran" => "Iran",
  111.                     "Iraq" => "Iraq",
  112.                     "Ireland" => "Ireland",
  113.                     "Israel" => "Israel",
  114.                     "Italy" => "Italy",
  115.                     "Jamaica" => "Jamaica",
  116.                     "Japan" => "Japan",
  117.                     "Jordan" => "Jordan",
  118.                     "Kazakhstan" => "Kazakhstan",
  119.                     "Kenya" => "Kenya",
  120.                     "Kiribati" => "Kiribati",
  121.                     "Kuwait" => "Kuwait",
  122.                     "Kyrgyzstan" => "Kyrgyzstan",
  123.                     "Laos" => "Laos",
  124.                     "Latvia" => "Latvia",
  125.                     "Lebanon" => "Lebanon",
  126.                     "Lesotho" => "Lesotho",
  127.                     "Liberia" => "Liberia",
  128.                     "Libya" => "Libya",
  129.                     "Liechtenstein" => "Liechtenstein",
  130.                     "Lithuania" => "Lithuania",
  131.                     "Luxembourg" => "Luxembourg",
  132.                     "Macedonia" => "Macedonia",
  133.                     "Madagascar" => "Madagascar",
  134.                     "Malawi" => "Malawi",
  135.                     "Malaysia" => "Malaysia",
  136.                     "Maldives" => "Maldives",
  137.                     "Mali" => "Mali",
  138.                     "Malta" => "Malta",
  139.                     "Mauritania" => "Mauritania",
  140.                     "Mauritius" => "Mauritius",
  141.                     "Mexico" => "Mexico",
  142.                     "Micronesia" => "Micronesia",
  143.                     "Moldova" => "Moldova",
  144.                     "Mongolia" => "Mongolia",
  145.                     "Montenegro" => "Montenegro",
  146.                     "Morocco" => "Morocco",
  147.                     "Mozambique" => "Mozambique",
  148.                     "Myanmar" => "Myanmar",
  149.                     "Namibia" => "Namibia",
  150.                     "Nauru" => "Nauru",
  151.                     "Nepal" => "Nepal",
  152.                     "Netherlands" => "Netherlands",
  153.                     "New Zealand" => "New Zealand",
  154.                     "Nicaragua" => "Nicaragua",
  155.                     "Niger" => "Niger",
  156.                     "Nigeria" => "Nigeria",
  157.                     "North Korea" => "North Korea",
  158.                     "Norway" => "Norway",
  159.                     "Oman" => "Oman",
  160.                     "Pakistan" => "Pakistan",
  161.                     "Palau" => "Palau",
  162.                     "Panama" => "Panama",
  163.                     "Papua new Guinea" => "Papua new Guinea",
  164.                     "Paraguay" => "Paraguay",
  165.                     "Peru" => "Peru",
  166.                     "Philippines" => "Philippines",
  167.                     "Poland" => "Poland",
  168.                     "Portugal" => "Portugal",
  169.                     "Qatar" => "Qatar",
  170.                     "Romania" => "Romania",
  171.                     "Russia" => "Russia",
  172.                     "Rwanda" => "Rwanda",
  173.                     "Saint Kitts And Nevis" => "Saint Kitts And Nevis",
  174.                     "Saint Lucia" => "Saint Lucia",
  175.                     "Saint Vincent And The Grenadines" => "Saint Vincent And The Grenadines",
  176.                     "Samoa" => "Samoa",
  177.                     "San Marino" => "San Marino",
  178.                     "Sao Tome and Principe" => "Sao Tome and Principe",
  179.                     "Saudi Arabia" => "Saudi Arabia",
  180.                     "Senegal" => "Senegal",
  181.                     "Serbia" => "Serbia",
  182.                     "Seychelles" => "Seychelles",
  183.                     "Sierra Leone" => "Sierra Leone",
  184.                     "Singapore" => "Singapore",
  185.                     "Slovakia" => "Slovakia",       
  186.                     "Slovenia" => "Slovenia",
  187.                     "Solomon Islands" => "Solomon Islands",
  188.                     "Somalia" => "Somalia",
  189.                     "South Africa" => "South Africa",
  190.                     "South Korea" => "South Korea",
  191.                     "South Sudan" => "South Sudan",
  192.                     "Spain" => "Spain",
  193.                     "Sri Lanka" => "Sri Lanka",
  194.                     "Sudan" => "Sudan",
  195.                     "Suriname" => "Suriname",
  196.                     "Swaziland" => "Swaziland",
  197.                     "Sweden" => "Sweden",
  198.                     "Switzerland" => "Switzerland",
  199.                     "Syria" => "Syria",
  200.                     "Taiwan" => "Taiwan",
  201.                     "Tajikistan" => "Tajikistan",
  202.                     "Tanzania" => "Tanzania",
  203.                     "Thailand" => "Thailand",
  204.                     "The Bahamas" => "The Bahamas",
  205.                     "Togo" => "Togo",
  206.                     "Tonga" => "Tonga",
  207.                     "Trinidad And Tobago" => "Trinidad And Tobago",
  208.                     "Tunisia" => "Tunisia",
  209.                     "Turkey" => "Turkey",
  210.                     "Turkmenistan" => "Turkmenistan",
  211.                     "Tuvalu" => "Tuvalu",
  212.                     "Uganda" => "Uganda",
  213.                     "Ukraine" => "Ukraine",
  214.                     "United Arab Emirates" => "United Arab Emirates",
  215.                     "United Kingdom" => "United Kingdom",
  216.                     "United States" => "United States",
  217.                     "Uruguay" => "Uruguay",
  218.                     "Uzbekistan" => "Uzbekistan",
  219.                     "Vanuatu" => "Vanuatu",
  220.                     "Venezuela" => "Venezuela",
  221.                     "Vietnam" => "Vietnam",
  222.                     "Virgin Islands (US)" => "Virgin Islands (US)",
  223.                     "Yemen" => "Yemen",
  224.                     "Zambia" => "Zambia",
  225.                     "Zimbabwe" => "Zimbabwe",
  226.                     "Others" => "Others"
  227.                 ], 'placeholder' => '------------------',
  228.             ])
  229.         ;
  230.     }
  231.     public function configureOptions(OptionsResolver $resolver): void
  232.     {
  233.         $resolver->setDefaults([
  234.             'data_class' => User::class,
  235.         ]);
  236.     }
  237. }