mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-20 22:53:49 +00:00
crudification for thirdparty
This commit is contained in:
@@ -67,7 +67,7 @@ class CenterTransformer implements DataTransformerInterface
|
||||
}
|
||||
|
||||
if ($this->multiple) {
|
||||
return new ArrayCollect($centers);
|
||||
return new ArrayCollection($centers);
|
||||
} else {
|
||||
return $centers[0];
|
||||
}
|
||||
|
@@ -24,6 +24,8 @@ use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
|
||||
use Chill\MainBundle\Security\Authorization\AuthorizationHelperInterface;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\CallbackTransformer;
|
||||
use Symfony\Component\Form\FormInterface;
|
||||
use Symfony\Component\Form\FormView;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
|
||||
@@ -41,7 +43,7 @@ use Symfony\Component\Security\Core\Security;
|
||||
*
|
||||
*
|
||||
*/
|
||||
class CenterType extends AbstractType
|
||||
class PickCenterType extends AbstractType
|
||||
{
|
||||
protected AuthorizationHelperInterface $authorizationHelper;
|
||||
|
||||
@@ -112,9 +114,8 @@ class CenterType extends AbstractType
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
$centers = $this->getReachableCenters($options['role'], $options['scopes']);
|
||||
dump($centers);
|
||||
|
||||
if (count($centers) <= 1) {
|
||||
dump($centers);
|
||||
$multiple = $options['choice_options']['multiple'] ?? false;
|
||||
$builder->add('center', HiddenType::class);
|
||||
$builder->get('center')->addModelTransformer(
|
||||
@@ -165,4 +166,9 @@ class CenterType extends AbstractType
|
||||
}
|
||||
}
|
||||
|
||||
public function buildView(FormView $view, FormInterface $form, array $options)
|
||||
{
|
||||
$view->vars['is_hidden'] = count($this->getReachableCenters($options['role'],
|
||||
$options['scopes'])) <= 1;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user