09.
Dynamically Remove the delete Action Link
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.
If you liked what you've learned so far, dive in! Subscribe to get access to this tutorial plus video, code and script downloads.
Whoops, an error! Please, try again later.
21 Comments
I try to rework this course in Symfony5. But any dump in easy_admin templates break the app with this error 'Uncaught PHP Exception Symfony\Component\ErrorHandler\Error\OutOfMemoryError: "Error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 65028096 bytes)" at /home/petrero/www/EasyAdmin/vendor/twig/twig/src/Extension/DebugExtension.php line 57'
I have a public repository at https://github.com/petre-sy... where is the entire app and is described the entire workflow in many commits. May be downloaded from there. What happen and how to remedy this?
Hey Diaconescu
I'm not sure if that's related to Symfony5 or to your local machine configuration. Do you have x-debug installed? If you open up the debug web toolbar, there is a section called "PHP Configuration" check if everything is configured
Cheers!
Thank you
You were right. xdebug wasn't installed.
Hello,
I have followed the example to unset a list action which work great on some of my lists but one of my lists is using the dropdown for it's lists actions. Is there a way to unset a list action on a dropdown?
Thank you in advance!
I figured out why the action was not getting removed from the dropdown. I was using a different list template where I did not have my filter so it was showing up. Sorry, I wasted a post.
Hey Brent
Don't worry about it. Disqus can store some extra bytes ;)
btw, EasyAdminBundle may be confusing to override some times
Hello,
templates/admin/list.html.twig
`{% extends '@EasyAdmin/default/list.html.twig' %}
{% block item_actions %}
{% set _list_item_actions = _list_item_actions|filter_admin_actions(item) %}
{{ dump(item_actions) }}
{{ parent() }}
{% endblock %}`
I don't see the dump.
Looks like the file hasn't been overrided.
the file must be placed in the template folder ? in an easy_admin folder?
thanks
Hey ojtouch
Yeah template overriding is a tricky thing, to override bundle templates, you should place it in:
templates/bundles/EasyAdminBundle/default/list.html.twigand your extends string will be like:
{% extends '@!EasyAdmin/default/list.html.twig' %}Then it will work as expected.
Cheers!
And if I add this on easy_admin.yaml file :
`entities:
I have this error :
Variable "item_actions" does not exist.<br />hm probably you should
dump(_list_item_actions)?Hello guys! How to know name of directory (f.e. easy_admin) which EasyAdminBundle will automatically to use instead of default?
Yo Billy Van!
This is a special feature of EasyAdminBundle. In the previous chapter, I quickly mention that in their docs, they talk about all the different options for overriding templates: https://symfony.com/doc/cur.... One of them is to create this easy_admin directory: the bundle is programmed to look there.
Cheers!
I’m getting the following error:
Unknown "filter_admin_actions" filter in easy_admin/list.html.twig at line 4.
I’ve created the file EasyAdminExtension.php, with the functions:
Also i’ve created the new folder easy_admin (app/resources/views/easy_admin) with the list.html.twig
List.html.twig looks like:
PHPStorm also says cannot found declaration for @EasyAdmin/def……….
When I compare my services.yml with the one from the course finish, it looks difference.
My service.yml looks like:
When I change my services.yml I get a new error:
A "tags" entry must be an array for service "AppBundle\Controller\" in /home/vagrant/documents/development/aqua_note/app/config/services.yml. Check your YAML syntax in /home/vagrant/documents/development/aqua_note/app/config/services.yml (which is being imported from "/home/vagrant/documents/development/aqua_note/app/config/config.yml").
How could I solve this issue?
Hey Bertin,
First of all, I see you have different indentation styles in one file, you use 4 spaces for it, but for the last service "app.form.help_form_extension" you use only 2 spaces. That could be a problem, first of all try to stick to a one style, I'd say it's easy to tweak the last service to use 4 spaces too for all:
Also, in the error message I see we're talking about "AppBundle\Controller\" service, but I don't see it in your output. Did you show the content of proper file? Could you show the content of "/home/vagrant/documents/development/aqua_note/app/config/services.yml"? Because the problem should be in it.
Cheers!
I've changed the indent to 4 spaces. Also my previous comment has the services.yml. But i will post it again.
<strong>services.xml (/home/vagrant/documents/development/aqua_note/app/config/services.yml)</strong>
But still getting the following error:
" Unknown "filter_admin_actions" filter in easy_admin/list.html.twig at line 4."
And if i take a look at file: easy_admin/list.html.twig it looks like:
It look likes the service is not enabled/configured but in the video they are mention it should
work because of autowiring / autoregistration / autoconfigure services.
Also mentioned before that my services.yml is different with the one from the start project directory.
The services.yml from the start directory looks like:
But when is use the services.yml from the start directory the following error accours
A "tags" entry must be an array for service "AppBundle\Controller\" in /home/vagrant/documents/development/aqua_note/app/config/services.yml. Check your YAML syntax in /home/vagrant/documents/development/aqua_note/app/config/services.yml (which is being imported from "/home/vagrant/documents/development/aqua_note/app/config/config.yml").
So i miss something but couldn't find out what
Hey Bertin,
OK, so first of all the root of the problem is that you don't have the new service auto-registration. This part is necessary for it:
So it should be at the top of your services.yml if you want to have service auto-registration. Let's add it to your services.yml. Do you still have the error about?
Please, try again and make sure you don't miss any brackets, etc. and your syntax is a valid YAML.
Btw, what version of Symfony do you use? Because this feature is new and does not work for Symfony version less than v3.3, see related discussion here: https://github.com/symfony/symfony-docs/issues/7988 . So the only way to use it is upgrade Symfony to 3.3 at least.
Cheers!
It's working again. It was a version problem. I used Symfony 3.1. After updating it with composer update its working. Thx for the help.
Hey Bertin,
Yay, glad we solved it finally ;)
Cheers!
Hello guys,
You set up in twig "_list_item_actions|filter_admin_actions(item)" with one argument 'item'.
But in Twig extension we have public function filterActions(array $itemActions, $item) with two arguments. How twig knows about $itemActions?
Am I missing something?
Yo Axa!
Good question! :) You're totally right, filterActions() requires 2 args, but you need to know how Twig filters work. The 1st argument to the Twig filter *is always* a value which is on the left of the pipe "|" char. In your case, the first argument to filterActions() is the value of "_list_item_actions" variable, because it's standing right before | filter_admin_actions(). So the *second* argument to filterActions() is always the *first* argument in Twig filer parentheses, i.e. "item" variable in "|filter_admin_actions(item)". Does it clear for you now? Also, you can read official docs about Twig filter: https://twig.symfony.com/do...
Cheers!
Hello Victor,
Yes, it is clear now. Thanks.
"Houston: no signs of life"
Start the conversation!