kunicmarko20 / SonataAnnotationBundle

Annotations for Sonata Admin
MIT License
21 stars 7 forks source link

Support for groups, tabs and field order? #31

Closed lukepass closed 3 years ago

lukepass commented 5 years ago

Hello and thanks for this awesome bundle!

Would it be possible to specify groups and tabs such as in admin classes? Would it be also possible to get the option to reorder the fields?

Something like this in classes:

$formMapper->reorder(['name', 'description', 'collection', 'category']);

Thanks!

kunicmarko20 commented 5 years ago

Would it be possible to specify groups and tabs such as in admin classes?

Will need to think about this one, one thing that comes to my mind is that field annotations have like a group name and when you specify it, it is added to group/tab.

Would it be also possible to get the option to reorder the fields?

Adding a priority option to field annotation should work.

Will try to find some time over the weekend and try to do one of these.

lukepass commented 5 years ago

Will need to think about this one, one thing that comes to my mind is that field annotations have like a group name and when you specify it, it is added to group/tab.

That would be perfect, I would also need the possibility to add some classes to the groups. Something like this:

->with('Profile', ['class' => 'col-md-6'])
    ->add('email')
    ->add('firstname')
    ->add('lastname')
->end()

Adding a priority option to field annotation should work.

This would also be a bless!

With these two small changes I would be able to completely drop the admin classes and make all the interfaces with annotations :smile:

Thank you very much!

kunicmarko20 commented 5 years ago

Group/Tab would have their own annotation so you would be able to add classes.

kunicmarko20 commented 5 years ago

https://github.com/kunicmarko20/SonataAnnotationBundle/pull/32 this adds the form field order

lukepass commented 5 years ago

Hello @kunicmarko20, how can I test this feature in composer.json?

Thanks!

kunicmarko20 commented 5 years ago

composer require kunicmarko/sonata-annotation-bundle 1.x-dev

I started on Groups and Tabs, it is gonna take bit more time than I expected.

kunicmarko20 commented 5 years ago

I hate sonata, these groups and tabs are complex, will try to finish it over the weekend.

kunicmarko20 commented 5 years ago

Finally found time to work on this, still need to add tests

lukepass commented 5 years ago

Hello Marko! I finally had time to test out your great new features!

Position

The position in FormField is working fine but I think it should be added to ListField and ShowField field too. Right now they don't have the position property.

P.S. maybe I can try to add them and push to the branch?

Groups and Tabs

The groups are working fine in the FormField but I think they should be added to ShowField field too.

I couldn't figure out how to make tabs working. This is a sample of my class:

/**
 * @Sonata\ListAction("show")
 * @Sonata\ListAction("edit")
 * @Sonata\ListAction("delete")
 * @Sonata\Group(name="TestGroup")
 * @Sonata\Tab(name="TestTab")
 */
class User extends BaseUser
{
    /**
     * @var string
     *
     * @Sonata\DatagridField()
     * @Sonata\ListField()
     * @Sonata\FormField(tab="TestTab")
     * @Sonata\ShowField()
     */
    protected $email;
}

I get this error:

No editable field defined. Did you forget to implement the "configureFormFields" method?

Thanks again for your work!

kunicmarko20 commented 5 years ago

Hey @lukepass, I didn't find time to finish this and I don't think I will soon. If you want to take over the PR it would be awesome, currently groups and positions only work with form fields, changing that to others will take a bit of a rework

lukepass commented 5 years ago

I created a pull request for the show field, I hope it's all good!

https://github.com/kunicmarko20/SonataAnnotationBundle/pull/36

Do you use php-cs-fixer? If yes, what settings are you using? So I can keep up with the same style.

Thanks.