datatables-bundle
datatables-bundle copied to clipboard
no support for OptionsResolver
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?
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
).
I think you might be confusing symfony's
FormType
withDataTableType
. AFAIK, theDataTableType
should not be used to create forms. (createFromType
is not the same ascreateFormType
). But apart from this, the answer to your question isno
. As far as the bundle knows, there is noconfigureOptions
method that can be called on anyDataTableType
. This is, however, supported for anyColumn
class (extending fromAbstractColumn
).
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.
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.
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 :)
Oh sorry, I've misunderstood your question then. I understand what you mean, I'll leave a review.
Stale issue message