mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 23:23:51 +00:00
selected periods are not coming through in POST. Value not valid
This commit is contained in:
@@ -99,38 +99,23 @@ class ReassignAccompanyingPeriodController extends AbstractController
|
||||
$paginator->getCurrentPageFirstItemNumber()
|
||||
);
|
||||
|
||||
// foreach ($periods as $period) {
|
||||
// $periodIds[] = $period->getId();
|
||||
// }
|
||||
$assignPeriods = [];
|
||||
|
||||
// $assignForm= $this->buildReassignForm($periods);
|
||||
$assignData = [];
|
||||
$assignForm = $this->createFormBuilder($assignData)
|
||||
->add('periods', ChoiceType::class, [
|
||||
// 'data' => serialize($periods),
|
||||
'choices' => $periods,
|
||||
'multiple' => true,
|
||||
'expanded' => true
|
||||
])
|
||||
->add('user', EntityType::class, [
|
||||
'class' => User::class,
|
||||
'choices' => $this->userRepository->findByActive(['username' => 'ASC']),
|
||||
'choice_label' => function (User $u) {
|
||||
return $this->userRender->renderString($u, []);
|
||||
},
|
||||
'placeholder' => 'Choose a user to reassign to',
|
||||
'multiple' => false,
|
||||
'label' => 'User',
|
||||
'required' => true,
|
||||
])
|
||||
->getForm();
|
||||
foreach($periods as $period) {
|
||||
$assignPeriods[$period->getId()] = $period;
|
||||
}
|
||||
|
||||
$assignForm = $this->buildReassignForm($assignPeriods);
|
||||
|
||||
$assignForm->handleRequest($request);
|
||||
|
||||
if ($assignForm->isSubmitted()) {
|
||||
|
||||
$periods = $assignForm->get('periods')->getData();
|
||||
$userAssign = $assignForm->get('user')->getData();
|
||||
$userAssign = $assignForm->get('assignUser')->getData();
|
||||
|
||||
dump($periods);
|
||||
dump($userAssign);
|
||||
|
||||
foreach($periods as $periodId) {
|
||||
$reassignPeriod = $this->courseRepository->find($periodId);
|
||||
@@ -188,30 +173,23 @@ class ReassignAccompanyingPeriodController extends AbstractController
|
||||
'label' => 'User',
|
||||
'required' => false,
|
||||
]);
|
||||
// ->add('periods', HiddenType::class, [
|
||||
// 'data' => serialize($periodIds),
|
||||
// ]);
|
||||
|
||||
return $builder->getForm();
|
||||
}
|
||||
|
||||
private function buildReassignForm(array $periods): FormInterface
|
||||
{
|
||||
$defaultData = [
|
||||
'user' => [],
|
||||
'periods' => $periods
|
||||
];
|
||||
$defaultData = [];
|
||||
|
||||
$builder = $this->formFactory->createBuilder(FormType::class, $defaultData, ['csrf_protection' => false, ]);
|
||||
|
||||
$builder
|
||||
->add('periods', ChoiceType::class, [
|
||||
// 'data' => serialize($periods),
|
||||
'choices' => $periods,
|
||||
'multiple' => true,
|
||||
'expanded' => true
|
||||
])
|
||||
->add('user', EntityType::class, [
|
||||
->add('assignUser', EntityType::class, [
|
||||
'class' => User::class,
|
||||
'choices' => $this->userRepository->findByActive(['username' => 'ASC']),
|
||||
'choice_label' => function (User $u) {
|
||||
@@ -223,6 +201,8 @@ class ReassignAccompanyingPeriodController extends AbstractController
|
||||
'required' => true,
|
||||
]);
|
||||
|
||||
$builder->get('periods')->resetViewTransformers();
|
||||
|
||||
return $builder->getForm();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user