<?php
// src/Form/UserType.php
namespace App\Form;
use App\Entity\User;
use App\Entity\UserShippingLocation;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Form\Extension\Core\Type\EmailType;
use Symfony\Component\Form\Extension\Core\Type\FileType;
use Symfony\Component\Form\Extension\Core\Type\TelType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\Extension\Core\Type\RepeatedType;
use Symfony\Component\Form\Extension\Core\Type\PasswordType;
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
use App\Form\Type\PhoneType;
use App\Form\UserLocationType;
class UserType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('firstName', TextType::class, array('label' => 'firstName'))
->add('lastName', TextType::class, array('label' => 'lastName'))
->add('displayName', TextType::class, array('label' => 'userName'))
->add('locale', ChoiceType::class, array(
'label' => 'language',
'choices' => array(
'french' => 'fr',
'english' => 'en'
)
))
->add('profileImage', FileType::class, array(
'mapped' => false,
'label' => 'profileImage',
'required' => false,
))
->add('email', EmailType::class)
->add('settingsReceiveMessageNotification', CheckboxType::class, array(
'label' => 'settingReceiveNotificationMessages',
'required' => false,
))
->add('plainPassword', RepeatedType::class, array(
'type' => PasswordType::class,
'first_options' => array('label' => 'newPasswordField', 'attr' => array('autocomplete' => 'new-password')),
'second_options' => array('label' => 'newPasswordConfirmField', 'attr' => array('autocomplete' => 'new-password')),
'required' => false
))
// ->add('shippingAddresses', CollectionType::class, array(
// 'entry_type' => UserLocationType::class,
// 'allow_add' => true,
// 'allow_delete' => true,
// 'prototype' => true,
// 'by_reference' => false,
// 'entry_options' => array('label' => false),
// 'label' => false
// ))
->add('save', SubmitType::class, array('label' => 'buttonSave', 'attr' => array('class' => 'btn-primary')));
}
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(array(
'data_class' => User::class,
));
}
}