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',
],
];
18 Comments
Hello!
I get this error when I try to run php bin/console importmap:require flowbite
Do you know why?
Hey @Octavio-B ,
Hm, it might be just a network issue or a temporary outage from jsDelivr. Or if you use a VPN or have some firewall set up - it may cause issues too. Could you try again after some time? Also, when you it this problem - try to load that URL directly in your browser, do you see a JSON output or is it not loaded as well?
Cheers!
Hello Victor,
Thank you for your quick response. You are right, it is a network issue; because when I try to load the URL directly in my browser, I don't get to see any JSON. I think it has to do with the firewall in my office. Is there another way to make this work?
Hey @Octavio-B ,
Hm, other than tweaking the firewall to allow it? Not sure, probably using a VPN may help, depends on the firewall setup, I think. Or use another CDN for this, probably the issue is only with this jsDelivr.
Cheers!
Hello everyone, I'm a French speaker and I use deepl to translate into English.
I need help with Symfony -UX-Autocomplete for a project I'm currently developing. I'm doing this in a stimulus controller that I've named test_controller.js
In my symfony form type, i have this:
But nothing happens in the browser console when I run the code and open dropdown.
I make it clear that the test_controller.js controller does work, I mean, is attached to my asset form field. When my page loads, the console tells me that the controller is active on my element. However, the autocomplete:open event, which should be activated when the Dropdown opens, doesn't work. Also, I've looked through all the available documentation about implementing @symfony/ux-autocomplete in a Symfony project, but haven't found anything about ux-autocomplete events.
Thanks for help :) !
Hey @Diarill!
Where did you get the event
autocomplete:openfrom? I don't believe that exists. I don't think UX autocomplete dispatches any event on open. However, the underlying autocomplete library "TomSelect" does dispatch some events: https://tom-select.js.org/docs/events/The implementation would look something like this (referencing https://symfony.com/bundles/ux-autocomplete/current/index.html#extending-tom-select)
Let me know if this helps!
Somehow I am not getting the form to autovalidate when the date changes with Flowbite's datepicker.
I have a date field with a NotNull constraint. The issue is noticeable when the date field is blank, the form is submitted and the not null validation error is displayed for the date field. Then selecting a date with the datepicker does not trigger the autovalidation.
It looks like the Flowbite's datepicker might be preventing the change event. The component does have a changeDate event, but I wouldn't know how to manually trigger LiveComponent's validation.
Hey @apphancer!
Hmm, I hadn't tried this yet, but it does make sense. Usually, when you have a "widget" like this, when you select a date it does, of course, update the underlying
inputwith the value. But it almost always does it in a way that does not trigger thechangeevent (iirc you need to do MORE work to have that happen). So you've diagnosed this perfectly.You can find the fix & info here - https://symfony.com/bundles/ux-live-component/current/index.html#model-updates-don-t-work-when-external-javascript-changes-a-field which really points down to here - https://symfony.com/bundles/ux-live-component/current/index.html#javascript-manual-element-change
Let me know if that helps!
Cheers!
Thanks, Ryan, for pointing me in the right direction. That was very helpful!
I think I've managed to get to the bottom of it, and.... it looks like the issue is more serious than I first imagined, and.... the datepicker in Space Inviters is affected by the same issue.
Not only the changes to this field are not submitted for validation, but if you select a date for a Voyage (i.e. a different date than the default one), then change anything in the other fields, the autovalidation triggered on the other fields resets the value selected in the date field.
Here's how I changed the code inside the connect method of the datepicker_controller:
Hey @apphancer!
Nice work! Sorry for the VERY slow reply. This is exactly the reason why we need to share Stimulus controllers as a community, so we can get little details like this correct. That's something we're working on right now for ux.symfony.com.
Cheers!
Ryan,
I may be having the same issue. I'm using LiveComponents to search through items with a Live Search, and I'm using Tailwind CSS Number Input by Flowbite, which requires Flowbite.js. The number input works, but if I search and the LiveComponent renders with the Items matched in the search, the number input still works, but if I clear the search, the number input no longer works.
I checked this:
https://symfony.com/bundles/ux-live-component/current/index.html#javascript-manual-element-change
So I've created a Stimulus controller:
And then I've added this to my component:
Is there something I'm missing?
Hey @Brandon!
Flowbite is great and a pain :).
Can you verify if:
initializemethod of your controller is being called?render:finishedcallback being executed?I'm not sure where the problem is, but that's where I would start looking. I bet other people would be interested in the solution if we can find it.
Cheers!
Ryan,
Thank you for the response. This what I've come up with
Initial page load, before any search takes place, in my console I get:
application #starting
render #initialize
render #connect
live #initialize
live #connect
application #start
I run a search which I know will return 1 result and I added a console.log('Render Finished?'); after initFlowbite();, and in my console for whatever reason it comes up three times.
Render Finished?
Render Finished?
Render Finished?
If I clear the search and return everything, it says 'Render Finished' once more and my number field works on the first 'item', but not on the other four, unless I do a full page refresh, and it works the same all over again. I don't know a lot about JavaScript, but if you suggest more to test I can do it to figure this out. I can say that there is an event on the first number input that works, but not on any of the others.
What I did to get around this is like you have suggested in the past, make a small Stimulus controller to handle the increment and decrement of the input, basically taking the place of Flowbite. It would be nice for Flowbite to work out of the box, but if I'm making a Stimulus controller to help re-render Flowbite, I might as well use the controller to work right out the box with LiveComponents and increment and decrement my quantity.
Thank you for all your help, I wish you the best
Hey @Brandon!
Nice job! And this really summarizes my feelings about the Flowbite JavaScript: it's super enticing, but the implementation is not what I want. The initialization code is really hardwired to depend on full page refreshes and definitely doesn't play well with the DOM mutation that LiveComponents uses (and that more and more things use, like Turbo 8 morphing). Ideally, as morphing becomes more common, libraries like Flowbite will work better with them. But until that fancy future, Flowbite offers these wonderful things that are beautiful and instant... until they stop working. Then you've gotta debug and it may or may not feel worth it in the end, which is a shame.
So good work, and I wish I had a magical solution, because I also want to use Flowbite more often :)
Cheers!
Thanks so much for this course, and really, all of them. The presentation style keeps me engaged and the videos are just the right length.
Six months ago I came back to PHP/Symfony and had to update a PHP 5.x / Symfony 2.x project to PHP 8 / Symfony 6.3 and this site has been invaluable for getting up to speed quickly. So much has advanced in the last 8 years since I lived it back in 2013 - 2015. Upgrading wasn't really an option so I ended up using the old code as a guide and just re-wrote the whole thing. Lines and lines of custom JS just vanished once I got using Stimulus and it was so much easier. It did remind me of how I have a love/hate relationship with Bootstrap. Then I watched the Tailwind videos here and just started using it this week and I love having all my style definitions right where I can see them. Also switched from Webpack to AssetMapper... so much easier.
Hey @Shay-H
Thanks for you kind words, we're here to help :)
Cheers!
Hey Ryan. Thanks for providing this bonus video.
To fix the form styles for dark mode/light mode you changed
darkModetomedia. I assume this is working for you because you use dark mode on your operating system, or at least your browser. But if someone following the lesson uses light mode in their browser, wouldn't the issue still remain? I think a better solution would be to addclass="dark"to the<html>element of the base template, since the entire app uses a dark theme and does not support toggling themes. I suggest adding that class to the<html>element only because that is what the flowbite docs suggest.Also, it's cool that you can opt to just use the flowbite-datepicker js and not the rest since that would be the one flowbite component with interactivity that would be the most painful to rebuild from scratch.
Hey @jdevine!
Yes - I get your point. I guess there are two ways of thinking about it:
1) I was imagining that, in a real app, you would be less lazy than I was and actually code the templates to properly support light mode. If you did that, then the auto-detection is perfectly great.
2) But, if we are determined to have this be a space-themed dark site only, then totally: we should use the
classand setclass="dark"like you suggested :).Ah! I'm really glad you thought so! I had the same thinking: all of the other JS (tabs, dropdowns, even the modal) seem relatively simple. A rich date picker on the other hand... yea, that's much bigger.
Cheers!
"Houston: no signs of life"
Start the conversation!