datatables-bundle icon indicating copy to clipboard operation
datatables-bundle copied to clipboard

no support for OptionsResolver

Open seizan8 opened this issue 3 years ago • 5 comments

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?

seizan8 avatar Oct 05 '21 12:10 seizan8

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).

Ahummeling avatar Jan 09 '22 22:01 Ahummeling

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.

seizan8 avatar Jan 10 '22 17:01 seizan8

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.

maxhelias avatar Jan 10 '22 18:01 maxhelias

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 :)

seizan8 avatar Jan 10 '22 19:01 seizan8

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

Ahummeling avatar Jan 13 '22 14:01 Ahummeling

Stale issue message

github-actions[bot] avatar Nov 19 '22 22:11 github-actions[bot]