omines / datatables-bundle

DataTables bundle for Symfony
https://omines.github.io/datatables-bundle/
MIT License
251 stars 113 forks source link

no support for OptionsResolver #243

Closed seizan8 closed 1 year ago

seizan8 commented 2 years ago

I created a datatable type by implementing the Omines\DataTablesBundle\DataTableTypeInterface. And in my controller I use $dataTableFactory->createFromType to generate the form. Adding a configureOptions(OptionsResolver $resolver) method to the form has no effect at all though. In symfony forms you can just configure your options like this. In the datatable form I don't see how you can do that.

Am doing something wrong or is there simply no support for the OptionsResolver?

Ahummeling commented 2 years ago

I think you might be confusing symfony's FormType with DataTableType. AFAIK, the DataTableType should not be used to create forms. (createFromType is not the same as createFormType). But apart from this, the answer to your question is no. As far as the bundle knows, there is no configureOptions method that can be called on any DataTableType. This is, however, supported for any Column class (extending from AbstractColumn).

seizan8 commented 2 years ago

I think you might be confusing symfony's FormType with DataTableType. AFAIK, the DataTableType should not be used to create forms. (createFromType is not the same as createFormType). But apart from this, the answer to your question is no. As far as the bundle knows, there is no configureOptions method that can be called on any DataTableType. This is, however, supported for any Column class (extending from AbstractColumn).

No. I use the dataTableFactory to create Table. I guess I said "to generate the form" which is not true. The factory does not return a form.

My point is, DataTableTypeInterface->configure let's you pass options to that method. So you can implement the interface and make your DataTableClass which you then use on the factory. The problem is that the OptionsResolver is not used and hence you have to deal with the validation. It would be really nice if the bundle used the OptionsResolver natively (for example in an abstract class), so you can simply overwrite the configureOptions method and it would take care of all the validations for you.

The OptionsResolver has not really much to do with Symfony forms. It's one of Symfony's components. It can and is used in many different services.

maxhelias commented 2 years ago

The OptionsResolver is already used to validate options on column. This can be interesting for DataTableType. To do this and avoid BC, it would be necessary to create a new interface which extends from the already existing.

seizan8 commented 2 years ago

The OptionsResolver is already used to validate options on column. This can be interesting for DataTableType. To do this and avoid BC, it would be necessary to create a new interface which extends from the already existing.

Yes. I did exactly that in my PR. Feel free to review it. I haven't contributed to many projects yet and would appreciate any feedback :)

Ahummeling commented 2 years ago

Oh sorry, I've misunderstood your question then. I understand what you mean, I'll leave a review.

github-actions[bot] commented 1 year ago

Stale issue message