mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 15:13:50 +00:00
user: add change location for user in user menu
This commit is contained in:
@@ -305,29 +305,20 @@ class UserController extends CRUDController
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param User $user
|
||||
* @return \Symfony\Component\Form\Form
|
||||
*/
|
||||
private function createEditLocationForm()
|
||||
{
|
||||
return $this->createForm(UserCurrentLocationType::class)
|
||||
->add('submit', SubmitType::class, ['label' => 'Change current location']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays a form to edit the user current location.
|
||||
*
|
||||
* @Route("/{_locale}/main/user/{id}/current-location/edit", name="chill_main_user_currentlocation_edit")
|
||||
* @Route("/{_locale}/main/user/current-location/edit", name="chill_main_user_currentlocation_edit")
|
||||
*/
|
||||
public function editCurrentLocationAction(User $user, Request $request)
|
||||
public function editCurrentLocationAction(Request $request)
|
||||
{
|
||||
$editForm = $this->createEditLocationForm();
|
||||
$editForm->handleRequest($request);
|
||||
$user = $this->getUser();
|
||||
$form = $this->createForm(UserCurrentLocationType::class, $user)
|
||||
->add('submit', SubmitType::class, ['label' => 'Change current location'])
|
||||
->handleRequest($request);
|
||||
|
||||
if ($editForm->isSubmitted() && $editForm->isValid()) {
|
||||
$currentLocation = $editForm->get('location')->getData();
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$currentLocation = $form->get('currentLocation')->getData();
|
||||
|
||||
$user->setCurrentLocation($currentLocation);
|
||||
|
||||
@@ -342,7 +333,7 @@ class UserController extends CRUDController
|
||||
|
||||
return $this->render('@ChillMain/User/edit_current_location.html.twig', [
|
||||
'entity' => $user,
|
||||
'edit_form' => $editForm->createView()
|
||||
'edit_form' => $form->createView()
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user