Skip to content
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

Enhance documentation on configuring global options for DataTableType. #172

Open
2mx opened this issue Jan 13, 2025 · 2 comments
Open

Enhance documentation on configuring global options for DataTableType. #172

2mx opened this issue Jan 13, 2025 · 2 comments
Labels
documentation Improvements or additions to documentation

Comments

@2mx
Copy link

2mx commented Jan 13, 2025

Unless I'm mistaken, I couldn't find any details in the documentation on how to configure global options, particularly how to set the #translation_domain option to avoid having to specify it for each column individually.

I can find the available options in the reference, but I don't see how to pass them to the builder.

I have try setOption('translation_domain', 'mydomain')

@Kreyu
Copy link
Owner

Kreyu commented Jan 13, 2025

You can define some default options for all data table types inside the bundle's configuration file:

https://data-table-bundle.swroblewski.pl/reference/configuration.html#data-table-builder-defaults

For anything other than that, if you want to modify any type class (e.g. change its defaults), you have to create a type extension class, exactly like in the Symfony's Form component, for example:

Or another example for the case you've described:

use Kreyu\Bundle\DataTableBundle\Extension\AbstractDataTableTypeExtension;
use Kreyu\Bundle\DataTableBundle\Type\DataTableType;
use Symfony\Component\OptionsResolver\OptionsResolver;

class DefaultConfigurationDataTableTypeExtension extends AbstractDataTableTypeExtension
{
    public function configureOptions(OptionsResolver $resolver): void
    {
        $resolver->setDefaults([
            'translation_domain' => 'mydomain',
        ]);
    }
    
    public static function getExtendedTypes(): iterable
    {
        return [DataTableType::class];
    }
}

@Kreyu Kreyu added dependencies Pull requests that update a dependency file documentation Improvements or additions to documentation and removed dependencies Pull requests that update a dependency file labels Jan 13, 2025
@2mx
Copy link
Author

2mx commented Jan 14, 2025

Ha ok ok ! Thank you very much for your detailed reply.
You did an amazing job !! I really enjoy to use you data table.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants