mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-13 13:54:23 +00:00
use fqdn in CenterType
This commit is contained in:
parent
a3e6b625b5
commit
bce6916837
@ -25,6 +25,8 @@ use Symfony\Component\Form\FormBuilderInterface;
|
|||||||
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage;
|
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage;
|
||||||
use Chill\MainBundle\Entity\Center;
|
use Chill\MainBundle\Entity\Center;
|
||||||
use Chill\MainBundle\Form\Type\DataTransformer\CenterTransformer;
|
use Chill\MainBundle\Form\Type\DataTransformer\CenterTransformer;
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
|
||||||
|
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -78,9 +80,9 @@ class CenterType extends AbstractType
|
|||||||
throw new \RuntimeException("The user is not associated with "
|
throw new \RuntimeException("The user is not associated with "
|
||||||
. "any center. Associate user with a center");
|
. "any center. Associate user with a center");
|
||||||
} elseif ($nbReachableCenters === 1) {
|
} elseif ($nbReachableCenters === 1) {
|
||||||
return 'hidden';
|
return HiddenType::class;
|
||||||
} else {
|
} else {
|
||||||
return 'entity';
|
return EntityType::class;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -93,7 +95,8 @@ class CenterType extends AbstractType
|
|||||||
public function configureOptions(OptionsResolver $resolver)
|
public function configureOptions(OptionsResolver $resolver)
|
||||||
{
|
{
|
||||||
if (count($this->reachableCenters) > 1) {
|
if (count($this->reachableCenters) > 1) {
|
||||||
$resolver->setDefault('class', 'Chill\MainBundle\Entity\Center');
|
$resolver->setDefault('class', Center::class);
|
||||||
|
$resolver->setDefault('choices', $this->reachableCenters);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -105,7 +108,7 @@ class CenterType extends AbstractType
|
|||||||
*/
|
*/
|
||||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||||
{
|
{
|
||||||
if ($this->getParent() === 'hidden') {
|
if ($this->getParent() === HiddenType::class) {
|
||||||
$builder->addModelTransformer($this->transformer);
|
$builder->addModelTransformer($this->transformer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user