Chapters
28 Chapters
|
2:24:59
|
Login to bookmark this video
-
Course Code
Subscribe to download the code!Compatible PHP versions: ^7.1.3
Subscribe to download the code!Compatible PHP versions: ^7.1.3
-
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!
26.
Form Events: A readonly Embedded Field
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.
This course is built on Symfony 3, but most of the concepts apply just fine to newer versions of Symfony.
What PHP libraries does this tutorial use?
// composer.json
{
"require": {
"php": "^7.1.3",
"symfony/symfony": "3.4.*", // v3.4.49
"doctrine/orm": "^2.5", // 2.7.5
"doctrine/doctrine-bundle": "^1.6", // 1.12.13
"doctrine/doctrine-cache-bundle": "^1.2", // 1.4.0
"symfony/swiftmailer-bundle": "^2.3", // v2.6.7
"symfony/monolog-bundle": "^2.8", // v2.12.1
"symfony/polyfill-apcu": "^1.0", // v1.23.0
"sensio/distribution-bundle": "^5.0", // v5.0.25
"sensio/framework-extra-bundle": "^3.0.2", // v3.0.29
"incenteev/composer-parameter-handler": "^2.0", // v2.1.4
"composer/package-versions-deprecated": "^1.11", // 1.11.99.4
"knplabs/knp-markdown-bundle": "^1.4", // 1.9.0
"doctrine/doctrine-migrations-bundle": "^1.1", // v1.3.2
"stof/doctrine-extensions-bundle": "^1.2" // v1.3.0
},
"require-dev": {
"sensio/generator-bundle": "^3.0", // v3.1.7
"symfony/phpunit-bridge": "^3.0", // v3.4.47
"nelmio/alice": "^2.1", // v2.3.6
"doctrine/doctrine-fixtures-bundle": "^2.3" // v2.4.1
}
}
6 Comments
Hi. I have a question. I tried to apply this readonly tips on my own app, but I'm facing a pb.
Example:
- I have 2 scientists for genus1, I add a new scientist. Then when I hit save, it deletes the 2 scientists and then add the new one.
- If I hit save without doing any changes, it deletes the actual genus scientists.
This is done as soon as I set up this readonly change
Any Idea?
Yo julien moulis!
Hmm. So, we're currently investigating a possible issue with the collection - there have been 2 other reports of weird issues. This stuff is way trickier than it needs to be :).
If you download the finish code from this course, do you see the same behavior? I'm curious if you're also hitting a weird issue, or if it's some small difference between your app and mine. Either way, sorry about the issues!
Cheers!
Hey I got it. So I have the same entities structure than the genus/scientis/genusScientist - Interview/user/interviewUser
In the InterviewUser join entity I set a extra field (boolean) that i didn't rendered on the form ( I did not need it here) and didn't set to any values in the constructor, so it was a null value. I guess doctrine 'thought' that because it was null, it had to be deleted. As soon as I sat a default value in the constructor, everything is working. But I still wander if it is best to use api ajax call than working with this prototype stuff... I would like to reproduce the add attendee google calendar... And I think it would be easier with the Api Ajax way. What do you think?
Hey julien moulis!
Fascinating! When I play with this stuff again, I'll try playing around with a similar setup. I cannot thing of why this would cause any difference - but, again, this stuff is hard!
And honestly, yes, in most cases, I would use a richer, AJAX-based interface rather than the complex collections situation. It's not only more reliable (because, as we know, this collection stuff is tough!) it's also a better use experience. It might take a bit more time to setup... which is why the collection stuff is nice in *some* situations (e.g. an admin interface... especially if your setup isn't too complex).
Cheers!
Hi . some help plz, i'm trying to enhance the application above , here we can only add one yearsStudied filed for every user .
Any idea How to: have many yearsStudied fileds for exmple the user1 have stadied 1 year php,2 year c++ ,2 year java and 1 year assembly.. i tried to change
->add('yearsStudied')
to :
->add('yearsStudied', CollectionType::class, array(
'entry_type' => YearsStudiedType::class,
),
));
In YearsStudiedType.php :
$builder->add('year_value');
Hey Ahmed!
That's an interesting feature you want to implement :)
You would have to do something similar to what we have done here with our "User - GenusScientist" relationship, where one GenusScientist might have many YearsStudied (OneToMany), you will have to create that new YearsStudied Entity, setup the relationship and create a new Admin Area for management .
I think you can re-apply all you have learnt in this tutorial in order to achieve your goal ;)
Cheers!
"Houston: no signs of life"
Start the conversation!