Skip to content
  • About
    • What is Symfony?
    • Community
    • News
    • Contributing
    • Support
  • Documentation
    • Symfony Docs
    • Symfony Book
    • Screencasts
    • Symfony Bundles
    • Symfony Cloud
    • Training
  • Services
    • Platform.sh for Symfony Best platform to deploy Symfony apps
    • SymfonyInsight Automatic quality checks for your apps
    • Symfony Certification Prove your knowledge and boost your career
    • SensioLabs Professional services to help you with Symfony
    • Blackfire Profile and monitor performance of your apps
  • Other
  • Blog
  • Download
sponsored by
  1. Home
  2. Documentation
  3. Bundles
  4. SonataAdminBundle
  5. iCheck

iCheck

Edit this page

The admin comes with iCheck integration. iCheck is a jQuery based checkbox and radio buttons skinning plugin. It provides a cross-browser and accessible solution to checkboxes and radio buttons customization.

The iCheck plugin is enabled on all checkbox and radio form elements by default.

Disable iCheck

If you don't want to use iCheck in your admin, you can disable it in configuration.

1
2
3
4
5
# config/packages/sonata_admin.yaml

sonata_admin:
    options:
        use_icheck: false # disable iCheck

Disable iCheck on some form elements

To disable iCheck on some checkbox or radio form elements, set data attribute data-sonata-icheck = "false" to this form element:

1
2
3
4
5
6
7
8
9
10
11
12
13
use Sonata\AdminBundle\Form\FormMapper;
use Sonata\AdminBundle\Form\Type\ModelType;

protected function configureFormFields(FormMapper $form): void
{
    $form
        ->add('category', ModelType::class, [
            'attr' => [
                'data-sonata-icheck' => 'false'
            ]
        ])
    ;
}

Note

You have to use false as string! "false"!

When using Sonata\AdminBundle\Form\Type\ChoiceFieldMaskType (or other types that inherit from it) with the expanded: true option (that renders the form type with checkboxes or radio buttons), it is necessary to set the data-sonata-icheck attribute on its choice elements:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
use Sonata\AdminBundle\Form\FormMapper;
use Sonata\AdminBundle\Form\Type\ModelType;
use Sonata\AdminBundle\Form\Type\ChoiceFieldMaskType;

protected function configureFormFields(FormMapper $form): void
{
    $form
        ->add('category', ChoiceFieldMaskType::class, [
            'expanded' => true,
            'placeholder_attr' => [
                // the placeholder (if any) needs also the data-sonata-icheck attr too since is rendered as
                // checkbox or radio button
                'data-sonata-icheck' => 'false'
            ],
            'choice_attr' => [
                'val1' => ['data-sonata-icheck' => 'false'],
                'val2' => ['data-sonata-icheck' => 'false'],
                // ...
            ],
        ])
    ;
}
This work, including the code samples, is licensed under a Creative Commons BY-SA 3.0 license.
TOC
    Version
    Take the exam at home

    Take the exam at home

    Peruse our complete Symfony & PHP solutions catalog for your web development needs.

    Peruse our complete Symfony & PHP solutions catalog for your web development needs.

    Version:

    Table of Contents

    • Disable iCheck
    • Disable iCheck on some form elements

    Symfony footer

    Avatar of inspiran, a Symfony contributor

    Thanks inspiran for being a Symfony contributor

    1 commit • 71 lines changed

    View all contributors that help us make Symfony

    Become a Symfony contributor

    Be an active part of the community and contribute ideas, code and bug fixes. Both experts and newcomers are welcome.

    Learn how to contribute

    Symfony™ is a trademark of Symfony SAS. All rights reserved.

    • What is Symfony?

      • What is Symfony?
      • Symfony at a Glance
      • Symfony Components
      • Symfony Releases
      • Security Policy
      • Logo & Screenshots
      • Trademark & Licenses
      • symfony1 Legacy
    • Learn Symfony

      • Symfony Docs
      • Symfony Book
      • Reference
      • Bundles
      • Best Practices
      • Training
      • eLearning Platform
      • Certification
    • Screencasts

      • Learn Symfony
      • Learn PHP
      • Learn JavaScript
      • Learn Drupal
      • Learn RESTful APIs
    • Community

      • Symfony Community
      • SymfonyConnect
      • Events & Meetups
      • Projects using Symfony
      • Contributors
      • Symfony Jobs
      • Backers
      • Code of Conduct
      • Downloads Stats
      • Support
    • Blog

      • All Blog Posts
      • A Week of Symfony
      • Case Studies
      • Cloud
      • Community
      • Conferences
      • Diversity
      • Living on the edge
      • Releases
      • Security Advisories
      • Symfony Insight
      • Twig
      • SensioLabs Blog
    • Services

      • SensioLabs services
      • Train developers
      • Manage your project quality
      • Improve your project performance
      • Host Symfony projects

      Powered by

    Follow Symfony