|
|
@@ -0,0 +1,103 @@ |
|
|
|
<?php |
|
|
|
|
|
|
|
namespace Lc\CaracoleBundle\Form\Address; |
|
|
|
|
|
|
|
use Lc\CaracoleBundle\Model\Address\AddressInterface; |
|
|
|
use Lc\CaracoleBundle\Model\Address\AddressModel; |
|
|
|
use Lc\SovBundle\Translation\TranslatorAdmin; |
|
|
|
use Symfony\Component\Form\Extension\Core\Type\ChoiceType; |
|
|
|
use Symfony\Component\Form\Extension\Core\Type\CollectionType; |
|
|
|
use Symfony\Component\Form\Extension\Core\Type\HiddenType; |
|
|
|
use Symfony\Component\Form\Extension\Core\Type\TextType; |
|
|
|
use Doctrine\ORM\EntityManagerInterface; |
|
|
|
use Symfony\Component\Form\AbstractType; |
|
|
|
use Symfony\Component\Form\FormBuilderInterface; |
|
|
|
use Symfony\Component\OptionsResolver\OptionsResolver; |
|
|
|
|
|
|
|
class AddressType extends AbstractType |
|
|
|
{ |
|
|
|
protected $em; |
|
|
|
protected $translatorAdmin; |
|
|
|
|
|
|
|
public function __construct(EntityManagerInterface $entityManager, TranslatorAdmin $translatorAdmin) |
|
|
|
{ |
|
|
|
$this->em = $entityManager; |
|
|
|
$this->translatorAdmin = $translatorAdmin; |
|
|
|
} |
|
|
|
|
|
|
|
public function buildForm(FormBuilderInterface $builder, array $options) |
|
|
|
{ |
|
|
|
$builder |
|
|
|
->add('title', TextType::class, ['label' => 'Titre']) |
|
|
|
->add( |
|
|
|
'type', |
|
|
|
ChoiceType::class, |
|
|
|
[ |
|
|
|
'label' => 'Type', |
|
|
|
'choices' => [ |
|
|
|
$this->translatorAdmin->transField( |
|
|
|
'typeOptions.'.AddressModel::TYPE_INDIVIDUAL, |
|
|
|
'Address' |
|
|
|
) => AddressModel::TYPE_INDIVIDUAL, |
|
|
|
$this->translatorAdmin->transField( |
|
|
|
'typeOptions.'.AddressModel::TYPE_LEGAL_PERSON, |
|
|
|
'Address' |
|
|
|
) => AddressModel::TYPE_LEGAL_PERSON, |
|
|
|
], |
|
|
|
] |
|
|
|
) |
|
|
|
->add( |
|
|
|
'civility', |
|
|
|
ChoiceType::class, |
|
|
|
[ |
|
|
|
'label' => 'Civilité', |
|
|
|
'required' => false, |
|
|
|
'choices' => [ |
|
|
|
'--' => '', |
|
|
|
'Femme' => 1, |
|
|
|
'Homme' => 0, |
|
|
|
], |
|
|
|
] |
|
|
|
) |
|
|
|
->add('lastname', TextType::class, ['required' => false]) |
|
|
|
->add('firstname', TextType::class, ['required' => false]) |
|
|
|
->add('zip', TextType::class) |
|
|
|
->add('city', TextType::class) |
|
|
|
->add('address', TextType::class) |
|
|
|
->add( |
|
|
|
'phone', |
|
|
|
CollectionType::class, |
|
|
|
[ |
|
|
|
'allow_add' => true, |
|
|
|
'allow_delete' => true, |
|
|
|
'entry_options' => [ |
|
|
|
'label' => false, |
|
|
|
], |
|
|
|
'required' => false, |
|
|
|
'row_attr' => array( |
|
|
|
'data-reindex-key' => true, |
|
|
|
'class' => 'field-collection', |
|
|
|
|
|
|
|
), |
|
|
|
'attr' => array( |
|
|
|
'class' => 'field-collection-group', |
|
|
|
), |
|
|
|
] |
|
|
|
) |
|
|
|
->add('company', TextType::class, ['required' => false]) |
|
|
|
->add('siret', TextType::class, ['required' => false]) |
|
|
|
->add('tva', TextType::class, ['required' => false]) |
|
|
|
->add('country', HiddenType::class, ['data' => 'France']) |
|
|
|
->add('status', HiddenType::class, ['data' => '1']); |
|
|
|
} |
|
|
|
|
|
|
|
public function configureOptions(OptionsResolver $resolver) |
|
|
|
{ |
|
|
|
$resolver->setDefaults( |
|
|
|
[ |
|
|
|
'label' => false, |
|
|
|
'data_class' => $this->em->getEntityName(AddressInterface::class), |
|
|
|
] |
|
|
|
); |
|
|
|
} |
|
|
|
} |