Chapters
32 Chapters
|
4:16:27
|
Login to bookmark this video
-
Course Code
Subscribe to download the code!
Subscribe to download the code!
-
This Video
Subscribe to download the video!
Subscribe to download the video!
-
Subtitles
Subscribe to download the subtitles!
Subscribe to download the subtitles!
-
Course Script
Subscribe to download the script!
Subscribe to download the script!
Scroll down to the script below, click on any sentence (including terminal blocks) to jump to that spot in the video!
Subscribe to jump to this part in the video!
Keep on Learning!
If you liked what you've learned so far, dive in! Subscribe to get access to this tutorial plus video, code and script downloads.
What PHP libraries does this tutorial use?
// composer.json
{
"require": {
"php": ">=8.2",
"ext-ctype": "*",
"ext-iconv": "*",
"babdev/pagerfanta-bundle": "4.x-dev", // 4.x-dev
"doctrine/doctrine-bundle": "^2.10", // 2.12.x-dev
"doctrine/doctrine-migrations-bundle": "^3.2", // 3.4.x-dev
"doctrine/orm": "^2.16", // 2.18.x-dev
"knplabs/knp-time-bundle": "dev-main", // dev-main
"pagerfanta/doctrine-orm-adapter": "4.x-dev", // 4.x-dev
"pagerfanta/twig": "4.x-dev", // 4.x-dev
"symfony/asset": "6.4.*", // 6.4.x-dev
"symfony/asset-mapper": "6.4.*", // 6.4.x-dev
"symfony/console": "6.4.x-dev", // 6.4.x-dev
"symfony/dotenv": "6.4.x-dev", // 6.4.x-dev
"symfony/flex": "^2", // 2.x-dev
"symfony/form": "6.4.x-dev", // 6.4.x-dev
"symfony/framework-bundle": "6.4.x-dev", // 6.4.x-dev
"symfony/monolog-bundle": "^3.0", // dev-master
"symfony/runtime": "6.4.x-dev", // 6.4.x-dev
"symfony/security-csrf": "6.4.x-dev", // 6.4.x-dev
"symfony/stimulus-bundle": "2.x-dev", // 2.x-dev
"symfony/twig-bundle": "6.4.x-dev", // 6.4.x-dev
"symfony/ux-autocomplete": "2.x-dev", // 2.x-dev
"symfony/ux-live-component": "2.x-dev", // 2.x-dev
"symfony/ux-turbo": "2.x-dev", // 2.x-dev
"symfony/ux-twig-component": "2.x-dev", // 2.x-dev
"symfony/validator": "6.4.x-dev", // 6.4.x-dev
"symfony/web-link": "6.4.*", // 6.4.x-dev
"symfony/yaml": "6.4.x-dev", // 6.4.x-dev
"symfonycasts/dynamic-forms": "dev-main", // dev-main
"symfonycasts/tailwind-bundle": "dev-main", // dev-main
"tales-from-a-dev/flowbite-bundle": "dev-main", // dev-main
"twig/extra-bundle": "^2.12|^3.0", // 3.x-dev
"twig/twig": "^2.12|^3.0" // 3.x-dev
},
"require-dev": {
"doctrine/doctrine-fixtures-bundle": "^3.4", // 3.6.x-dev
"phpunit/phpunit": "^9.5", // 9.6.x-dev
"symfony/browser-kit": "6.4.*", // 6.4.x-dev
"symfony/css-selector": "6.4.*", // 6.4.x-dev
"symfony/debug-bundle": "6.4.x-dev", // 6.4.x-dev
"symfony/maker-bundle": "^1.51", // dev-main
"symfony/panther": "^2.1", // v2.1.1
"symfony/phpunit-bridge": "7.1.x-dev", // 7.1.x-dev
"symfony/stopwatch": "6.4.x-dev", // 6.4.x-dev
"symfony/web-profiler-bundle": "6.4.x-dev", // 6.4.x-dev
"zenstruck/browser": "1.x-dev", // 1.x-dev
"zenstruck/foundry": "^1.36" // 1.x-dev
}
}
What JavaScript libraries does this tutorial use?
// importmap.php
return [
'app' => [
'path' => './assets/app.js',
'entrypoint' => true,
],
'js-confetti' => [
'version' => '0.11.0',
],
'@hotwired/stimulus' => [
'version' => '3.2.2',
],
'@symfony/stimulus-bundle' => [
'path' => './vendor/symfony/stimulus-bundle/assets/dist/loader.js',
],
'tom-select' => [
'version' => '2.3.1',
],
'tom-select/dist/css/tom-select.default.css' => [
'version' => '2.3.1',
'type' => 'css',
],
'@hotwired/turbo' => [
'version' => '7.3.0',
],
'stimulus-popover' => [
'version' => '6.2.0',
],
'debounce' => [
'version' => '1.2.1',
],
'turbo-view-transitions' => [
'version' => '0.3.0',
],
'stimulus-use' => [
'version' => '0.52.1',
],
'flowbite' => [
'version' => '2.2.1',
],
'@popperjs/core' => [
'version' => '2.11.8',
],
'flowbite-datepicker' => [
'version' => '1.2.6',
],
];
13 Comments
I did everything from this tutorial video. The turbo-frame gets the HTML from the view.
But the modal_controller doesnt trigger to open the dialog.
I have 2 errors in the browser console:
I work with the Encore build stuff, and I get the error with the 'npm run build' in the console
I cant find anything about missing file 'turbo-view-transitions' on stackoverflow, so is here anyone that can help me?
Hey @Bart-V
I just answered your other message, but I just realized that you're using Webpack Encore, not AssetMapper, right? In general, you need to install the package
turbo-view-transitionsand rebuild your assetsCheers!
Hey,
I did run this is the console 'php bin/console importmap:require turbo-view-transitions'.
I removed the old node_module folder and reinstall through 'npm install'.
But still it gives the same error.
I cannt find anything on how to install it with webpack Encore. And i am new in the Symfony and Encore world.
I see your problem, you're using both asset managers (Webpack and AssetMapper). This tutorial is focused on using AssetMapper, so if you want to follow along but use Webpack, you need to install and configure Webpack Encore in your project.
We have a specific tutorial about it here https://symfonycasts.com/screencast/webpack-encore
Cheers!
Hello,
I am having a bit of a problem getting the content to load in the turbo-frame in the dialog. I followed the video, and when I click new voyage, the turbo-frame says completed, but there is nothing inside. I made sure to surround the new.html.twig with <turbo-frame id=modal>, but I don't know what else to do. Can you help me trouble shoot this?
Thank you.
Hey @Skylar
Can you check if there are any errors in the web console toolbar? Also, inspect your modal after clicking the button and check if the HTML is inside it. Something odd it's going on
Cheers!
This is what the element looks like after the button is clicked <turbo-frame id="modal" data-modal-target="dynamicContent" src="https://127.0.0.1:8000/planet/new" complete> </turbo-frame>
Ok, so there's your issue. When you click on the "new" button it should fetch the content of the new voyage form and put it inside the modal element. Double-check your templates, something funny is going on in there
Cheers!
Thank you for responding!
I checked the toolbar and the console and could not find an error. I also checked the modal turbo-frame and there was no html inside it.
Ryan,
I have several modal pages, and I just ran into a spot where a button that lives in a modal would need to go to another modal, which is fine for my UI experience, but what is the best way to return someone back to the previous modal they came from?
Hey @Brandon!
That is something I thought about tackling in this tutorial, but eventually didn't, because it's potentially a pretty complex problem. In short, I'm not sure! It only makes senes to have a single
<dialog>open viashowModal()on the page at once. So you're not really opening another modal... but really you're replacing the dialog's content with other content.In theory, the solution might be relatively simple. If your modal content opens inside a
<turbo-frame id="modal">, then any link clicks or even redirects to another page would cause that content's page to also be shown in the modal (assuming that page, of course, extends themodalBase.html.twigso that the page returns inside of amodalframe). The tricky part is that, when you do this, your previous dialog content is lost: it was replaced. That might be ok in some cases, but I feel like this workflow is normally done because you're on FormA inside the modal, then want to go to FormB real quick to create something... so you can come back and continue filling out FormB. I just don't have a generic solution in mind for that yet. I'm sure it's possible, but I'd have to sit and hack on it for awhile.So, I don't have a great answer for you yet on this one. If anything comes to your mind, I'd love to know.
Cheers!
at this point I have a problem with modal controller not connecting to dynamiContent target. I got this error:
Modal with id dynamicContent does not exist. Are you sure that the data-modal-target attribute points to the correct dynamicContent id?.
The problem is that flowbite has some js witch uses data-modal-target and conflicts (https://github.com/themesberg/flowbite/blob/6f331833e39f696142eda720b622ce24b7594751/src/components/modal/index.ts#L271)
I changed the controller name from modal_controller to leihoa_controller and changed related stuff and now works ok.
Hey @ik3rib!
Sorry for the slow reply - holidays! Yea, if you're using the Flowbite JS, there is an unfortunate naming collision. I'm adding a bonus chapter - https://symfonycasts.com/screencast/last-stack/flowbite - to talk about Flowbite, this part included. The tl;dr is:
A) I don't use the Flowbite js, but you can
B) If you do, yea, probably the best fix is to NOT have a Stimulus controller named
modalorpopover- i.e. rename it like you proposed.Cheers!
"Houston: no signs of life"
Start the conversation!