Search by

nowo-tech / select-all-choice-bundle

HecFranco

Symfony bundle that adds a 'Select all' checkbox for ChoiceType fields with multiple=true (expanded or select).

Package info

github.com/nowo-tech/SelectAllChoiceBundle

Language:TypeScript

Type:symfony-bundle

pkg:composer/nowo-tech/select-all-choice-bundle

Fund package maintenance!

HecFranco

Statistics

Installs: 3 756

Dependents: 0

Suggesters: 1

Stars: 0

Open Issues: 0

v1.5.6 2026-09-27 16:22 UTC

README

CI Packagist Version Packagist Downloads License PHP Symfony

⭐ Found this useful? Give it a star on GitHub so more developers can find it.

Symfony bundle that adds an optional "Select all" checkbox for ChoiceType fields with multiple=true — for both expanded (checkboxes) and collapsed (select multiple) rendering. Frontend-driven: the backend marks the field and passes config via data attributes; a Stimulus controller creates and manages the toggle in the browser. Built with TypeScript and Vite (no Webpack Encore, no Importmap). For Symfony 6, 7 and 8 · PHP 8.2+.

FrankenPHP Friendly Worker Mode

This bundle is FrankenPHP worker mode friendly — including FRANKENPHP_RESET_KERNEL unset/false (kernel reused). See docs/FRANKENPHP-WORKER-AUDIT.md.

Demo page with navbar and select-all choices unchecked
Full demo — select-all unchecked
Demo page with navbar and all select-all toggles checked
Full demo — select-all checked

Table of contents

Quick search terms

Looking for Symfony ChoiceType select all, multiple choice select all checkbox, Stimulus form select all, Symfony form expanded choice, multi-select select all, ChoiceType Stimulus, Symfony 7 8 select all? You're in the right place.

Features

  • ✅ Opt-in — "Select all" appears only when the field has select_all => true
  • ✅ Two modes — Works with expanded=true (checkboxes) and expanded=false (multi-select)
  • ✅ Translatable label — Default key form.select_all, overridable with select_all_label; 60 languages included
  • ✅ Configurable — Position (before/after), CSS classes for toggle and container
  • ✅ Sync state — Toggle reflects "all selected" / "none" / indeterminate; manual selection updates the toggle
  • ✅ Events — Dispatches change with bubbles: true so other libs (TomSelect, validators) can react
  • ✅ Multiple fields — Safe with several select-all choice fields on the same page
  • ✅ Frontend-driven — Backend passes config via data attributes; a small script or Stimulus controller creates and manages the checkbox in the DOM
  • ✅ Works with or without Stimulus — Include the built select-all-choice.js script for auto-init (and dynamic content via MutationObserver), or register the Stimulus controller if your app already uses it
  • ✅ TypeScript + Vite — Bundle assets are TypeScript; the bundle ships a built IIFE for standalone use; your app’s Vite can also import the controller (no Encore/Importmap)
  • ✅ Compatible with Symfony 7 and 8 and FrankenPHP worker mode with FRANKENPHP_RESET_KERNEL unset/false (demo default FRANKENPHP_MODE=worker; set classic for per-request PHP)

Installation

composer require nowo-tech/select-all-choice-bundle

1. Register the bundle in config/bundles.php:

<?php

return [
  // ...
  Nowo\SelectAllChoiceBundle\NowoSelectAllChoiceBundle::class => ['all' => true],
];

2. Form theme: The bundle automatically adds its form theme from the form_theme option (see Configuration). Set form_theme in config/packages/nowo_select_all_choice.yaml to match your app (e.g. bootstrap_5_layout.html.twig). You do not need to add it to twig.form_themes unless you want to control the order.

3. Include the frontend script — Either include the built script (no Stimulus required) using the named asset package:

<script src="{{ asset(nowo_select_all_choice_asset_path('select-all-choice.js'), nowo_select_all_choice_asset_package()) }}" defer></script>

(or asset('select-all-choice.js', 'nowo_select_all_choice') — see docs/USAGE.md), or integrate the Stimulus controller via Vite (see docs/INSTALLATION.md).

4. (Optional) Translations — Default domain NowoSelectAllChoiceBundle with 60 languages; override via config or per-field options (see docs/CONFIGURATION.md).

Full steps (path repository, Vite alias, Option B copy assets): docs/INSTALLATION.md.

Requirements

  • PHP >= 8.2
  • Symfony 7 or 8 (^7.0 || ^8.0)
  • Stimulus optional — use the built select-all-choice.js script for standalone auto-init, or Stimulus (e.g. symfony/stimulus-bundle) if you register the controller in your app bundle
  • Vite to build the bundle’s assets (or use the pre-built script from the bundle’s public dir)

See docs/INSTALLATION.md for details.

Configuration

Create config/packages/nowo_select_all_choice.yaml to override defaults:

nowo_select_all_choice:
 form_theme: 'form_div_layout.html.twig'  # or 'bootstrap_5_layout.html.twig', etc.
 default_label: 'form.select_all'
 default_position: 'before'         # 'before' | 'after'
 default_toggle_css_class: 'form-check-input'
 default_wrapper_css_class: 'form-check'
 default_label_css_class: 'form-check-label'
 default_container_css_class: 'form-check mb-2'
 translation_domain: 'NowoSelectAllChoiceBundle'
 debug: false                # set true to log Stimulus/controller messages to the browser console

Set form_theme to match your app’s form layout (e.g. bootstrap_5_layout.html.twig). See docs/CONFIGURATION.md for all options and available Symfony form themes.

Usage

Enable "Select all" on a multiple choice field with the select_all option:

use Symfony\Component\Form\Extension\Core\Type\ChoiceType;

$builder->add('roles', ChoiceType::class, [
  'choices' => [
    'Admin' => 'ROLE_ADMIN',
    'User' => 'ROLE_USER',
    'Guest' => 'ROLE_GUEST',
  ],
  'multiple' => true,
  'expanded' => true,
  'select_all' => true,
]);

Override label, position and CSS per field; see docs/USAGE.md for all per-field options and examples.

Demo

The Symfony 8 demo is in demo/symfony8. Run from the bundle root: make up-symfony8 (http://localhost:8008). See demo/README.md for details.

The demo runs FrankenPHP with default FRANKENPHP_MODE=worker (worker { file …; watch } + Hot Reload). Set FRANKENPHP_MODE=classic for per-request PHP. Leave FRANKENPHP_RESET_KERNEL unset. Details: docs/DEMO-FRANKENPHP.md and docs/FRANKENPHP-WORKER-AUDIT.md.

Development

make -C demo/symfony8 test-e2e
make -C demo/symfony8 demo-screenshots   # refreshes docs/images/demo/*.png

Run tests and QA with Docker: make up && make install && make test (or make test-coverage, make qa). Without Docker: composer install && composer test. See Makefile for all targets.

Documentation

Additional documentation

Tests and coverage

  • Tests: PHPUnit (PHP), Vitest (TS/JS)
  • PHP: 100%
  • TS/JS: 100%

License

The MIT License (MIT). Please see LICENSE for more information.

Author

Created by Nowo.tech