mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-20 14:43:49 +00:00
handle kind as contacts
This commit is contained in:
@@ -18,14 +18,11 @@ use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\CallbackTransformer;
|
||||
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\Form\FormInterface;
|
||||
use Symfony\Component\Form\FormView;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
|
||||
use Chill\ThirdPartyBundle\Security\Voter\ThirdPartyVoter;
|
||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||
use Symfony\Component\Security\Core\Role\Role;
|
||||
use Chill\ThirdPartyBundle\ThirdPartyType\ThirdPartyTypeManager;
|
||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
@@ -64,7 +61,6 @@ class ThirdPartyType extends AbstractType
|
||||
*/
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
|
||||
$builder
|
||||
->add('name', TextType::class, [
|
||||
'required' => true
|
||||
@@ -111,7 +107,7 @@ class ThirdPartyType extends AbstractType
|
||||
;
|
||||
|
||||
// Contact Person ThirdParty (child)
|
||||
if ($options['is_child']) {
|
||||
if (ThirdParty::KIND_CONTACT === $options['kind'] || ThirdParty::KIND_CHILD === $options['kind']) {
|
||||
$builder
|
||||
->add('civility', EntityType::class, [
|
||||
'label' => 'thirdparty.Civility',
|
||||
@@ -156,6 +152,27 @@ class ThirdPartyType extends AbstractType
|
||||
'label' => 'thirdparty.Acronym',
|
||||
'required' => false
|
||||
])
|
||||
->add('activeChildren', ChillCollectionType::class, [
|
||||
'entry_type' => ThirdPartyType::class,
|
||||
'entry_options' => [
|
||||
'is_child' => true,
|
||||
'block_name' => 'children',
|
||||
'kind' => ThirdParty::KIND_CHILD,
|
||||
],
|
||||
'block_name' => 'active_children',
|
||||
'allow_add' => true,
|
||||
'allow_delete' => true,
|
||||
'by_reference' => false,
|
||||
'button_add_label' => "Add a contact",
|
||||
'button_remove_label' => "Remove a contact",
|
||||
'empty_collection_explain' => "Any contact"
|
||||
])
|
||||
;
|
||||
}
|
||||
|
||||
if (ThirdParty::KIND_CHILD !== $options['kind']) {
|
||||
|
||||
$builder
|
||||
->add('categories', EntityType::class, [
|
||||
'label' => 'thirdparty.Categories',
|
||||
'class' => ThirdPartyCategory::class,
|
||||
@@ -170,20 +187,6 @@ class ThirdPartyType extends AbstractType
|
||||
'multiple' => true,
|
||||
'attr' => ['class' => 'select2']
|
||||
])
|
||||
->add('activeChildren', ChillCollectionType::class, [
|
||||
'entry_type' => ThirdPartyType::class,
|
||||
'entry_options' => [
|
||||
'is_child' => true,
|
||||
'block_name' => 'children'
|
||||
],
|
||||
'block_name' => 'active_children',
|
||||
'allow_add' => true,
|
||||
'allow_delete' => true,
|
||||
'by_reference' => false,
|
||||
'button_add_label' => "Add a contact",
|
||||
'button_remove_label' => "Remove a contact",
|
||||
'empty_collection_explain' => "Any contact"
|
||||
])
|
||||
->add('active', ChoiceType::class, [
|
||||
'label' => 'thirdparty.Status',
|
||||
'choices' => [
|
||||
@@ -192,8 +195,7 @@ class ThirdPartyType extends AbstractType
|
||||
],
|
||||
'expanded' => true,
|
||||
'multiple' => false
|
||||
])
|
||||
;
|
||||
]);
|
||||
|
||||
// add the types
|
||||
$types = [];
|
||||
@@ -242,6 +244,7 @@ class ThirdPartyType extends AbstractType
|
||||
$resolver->setDefaults(array(
|
||||
'data_class' => ThirdParty::class,
|
||||
'is_child' => false,
|
||||
'kind' => null
|
||||
));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user