New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "exclude_fields" config option as mirror to "fields" #2325

Closed
TomasVotruba opened this Issue Aug 18, 2018 · 2 comments

Comments

Projects
None yet
2 participants
@TomasVotruba
Copy link
Contributor

TomasVotruba commented Aug 18, 2018

At the moment I can define fields to display in fields key.

It depends on each particular case if there is more fields to include or to exclude, but in my case I do this only to exclude ones I don't need. For example - to hide 1 one to many relation I have to do this:

easy_admin:
    entities:
        Training:
            class: 'App\Entity\Training'
            form:
                fields: ['name', 'content', 'perex', 'price', 'capacity', 'limit']

Then I develop my application and I added property $photo to my App\Entity\Training entity. I've updated the admin and nothing happened. After 5 minutes I realized I have to update the config.

 easy_admin:
     entities:
         Training:
             class: 'App\Entity\Training'
             form:
-                 fields: ['name', 'content', 'perex', 'price', 'capacity', 'limit']
+                 fields: ['name', 'content', 'perex', 'price', 'capacity', 'limit', 'photo']

This happened to me 3 times during last 2 days.
Instead of doing this back and forth and though *if there would be exclude_field option, I would do it once and forget.

 easy_admin:
     entities:
         Training:
             class: 'App\Entity\Training'
             form:
-                 fields: ['name', 'content', 'perex', 'price', 'capacity', 'limit']
+                 exclude_fields: ['terms']

These options could be mutually excludable, to prevent config confusion A-B.
I saw there is ConfigPass in form of collector - awesome job 👍 🎉

It would be slightly better if NormalizerConfigPass would not be first, because it copies all data to subnodes so the only way to add own ConfigPass is to go first and do all other passes' job manually.

But never the less, I've intergreated working proof of concept using ConfigPass with priority 120: DeprecatedPackages/open-training@db7536c#diff-318660bf4cd1ad8a5d0e608e94df8fae


What do you think?

@javiereguiluz

This comment has been minimized.

Copy link
Collaborator

javiereguiluz commented Sep 29, 2018

I've been thinking about this and I've decided to not implement it. The reason is that for real apps (not quick prototypes) is not that common to say: "add all fields, except these ones, and do whatever you want to do them". In real apps you must configure fields to make them display/behave like you want. So you must configure the fields and thus, adding them manually is not a big deal.

Also, the true real problem is that we repeat the same config again and again for fields. We should have a single method/config for all fields (the same done by the Nova admin generator; see https://nova.laravel.com/docs/1.0/resources/fields.html). We'll fix this in the future.

Even your proposal didn't make it this time, I thank you for opening this issue and helping us improve this bundle. Thanks!

@TomasVotruba

This comment has been minimized.

Copy link
Contributor

TomasVotruba commented Sep 29, 2018

It's different project from project. In prototype I don't care what's displayed and what not, I'm fine with all. With real app I'm building (2 actually), I need to control what to show and what not and don't care about it with every new single property. I'm lazy and product focused instead.

I forgot to mention here that that this feature made it to:
https://github.com/alterphp/EasyAdminExtensionBundle

Very good package with all that's missing in this package 👍 . No need to have that in core then.

If anyone needs it, just install the package and use exactly the same way as described above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment