Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Swup/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ The main usage of Symfony UX Swup is to use its Stimulus controller to initializ
<html lang="en">
<head>
<title>Swup</title>

{% block javascripts %}
{{ encore_entry_script_tags('app') }}
{% endblock %}
Expand Down Expand Up @@ -66,7 +66,7 @@ additional containers, for instance to have a navigation menu that updates when
<html lang="en">
<head>
<title>Swup</title>

{% block javascripts %}
{{ encore_entry_script_tags('app') }}
{% endblock %}
Expand Down
18 changes: 15 additions & 3 deletions src/Turbo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,10 @@ class TaskController extends AbstractController
$form = $this->createForm(TaskType::class, $task);
$form->handleRequest($request);

if ($form->isSubmitted() && $form->isValid()) {
$submitted = $form->isSubmitted();
$valid = $submitted && $form->isValid();

if ($valid) {
$task = $form->getData();
// ... perform some action, such as saving the task to the database

Expand All @@ -183,12 +186,21 @@ class TaskController extends AbstractController

// If the client doesn't support JavaScript, or isn't using Turbo, the form still works as usual.
// Symfony UX Turbo is all about progressively enhancing your apps!
return $this->redirectToRoute('task_success');
return $this->redirectToRoute('task_success', [], Response::HTTP_SEE_OTHER);
}

return $this->render('task/new.html.twig', [
// Symfony 5.3+
return $this->renderForm('task/new.html.twig', $form);

// Older versions
$response = $this->render('task/new.html.twig', [
'form' => $form->createView(),
]);
if ($submitted && !$valid) {
$response->setStatusCode(Response::HTTP_UNPROCESSABLE_ENTITY);
}

return $response;
}
}
```
Expand Down