PHPackages                             afzalsabbir/toggle-field-for-backpack - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Admin Panels](/categories/admin)
4. /
5. afzalsabbir/toggle-field-for-backpack

ActiveLibrary[Admin Panels](/categories/admin)

afzalsabbir/toggle-field-for-backpack
=====================================

Easily toggle boolean attributes with a new field type.

v2.0.1(3y ago)04MITBlade

Since Jun 24Pushed 3y ago1 watchersCompare

[ Source](https://github.com/AfzalSabbir/toggle-field-for-backpack)[ Packagist](https://packagist.org/packages/afzalsabbir/toggle-field-for-backpack)[ Docs](https://github.com/afzalsabbir/toggle-field-for-backpack)[ RSS](/packages/afzalsabbir-toggle-field-for-backpack/feed)WikiDiscussions main Synced today

READMEChangelog (1)Dependencies (1)Versions (2)Used By (0)

Toggle Field for Backpack 4 &amp; 5
===================================

[](#toggle-field-for-backpack-4--5)

[![Latest Version on Packagist](https://camo.githubusercontent.com/46fb2e4492f6e7c90c61c68ef4468951cdf5c07bfeffdd67481056948666e175/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f61667a616c7361626269722f746f67676c652d6669656c642d666f722d6261636b7061636b2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/afzalsabbir/toggle-field-for-backpack)[![Total Downloads](https://camo.githubusercontent.com/8ba8839103f34f3279c47a621f55399b2cc5e783cade84f28ad3df889a60496e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f61667a616c7361626269722f746f67676c652d6669656c642d666f722d6261636b7061636b2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/afzalsabbir/toggle-field-for-backpack)

> **Warning**This field is not compatible with `CRUD JS API` since it is a non-JS solution. Check [this answer](https://github.com/DigitallyHappy/toggle-field-for-backpack/issues/10#issuecomment-1163235431) until we provide a built-in solution in Backpack that can be used to replace this one.

This package provides a `toggle` field type for the [Backpack for Laravel](https://backpackforlaravel.com/) administration panel. The `toggle` field allows admins to ***toggle* the value of a boolean variable between true/false, in a prettier way**. It uses a CSS-only solution, so it has zero external dependencies and zero javascript.

> **This package has been created to make it easy for developers to share their custom fields with the Backpack community. You can use this package to get the `toggle` field type, sure. But you can also fork it, to create a Backpack addon. For more information on how to do this, check out Backpack's addon docs.**

Screenshots
-----------

[](#screenshots)

[![Backpack Toggle Field Addon](https://user-images.githubusercontent.com/1032474/74032390-7db64d00-49bc-11ea-80dc-b7c84b2c2e65.png)](https://user-images.githubusercontent.com/1032474/74032390-7db64d00-49bc-11ea-80dc-b7c84b2c2e65.png)

Installation
------------

[](#installation)

Via Composer

```
composer require afzalsabbir/toggle-field-for-backpack
```

Usage
-----

[](#usage)

Inside your custom CrudController:

```
$this->crud->addField([
    'name' => 'agreed',
    'label' => 'I agree to the terms and conditions',
    'type' => 'toggle',
    'view_namespace' => 'toggle-field-for-backpack::fields',
]);
```

Notice the `view_namespace` attribute - make sure that is exactly as above, to tell Backpack to load the field from this *addon package*, instead of assuming it's inside the *Backpack\\CRUD package*.

Overwriting
-----------

[](#overwriting)

If you need to change the field in any way, you can easily publish the file to your app, and modify that file any way you want. But please keep in mind that you will not be getting any updates.

**Step 1.** Copy-paste the blade file to your directory:

```
# create the fields directory if it's not already there
mkdir -p resources/views/vendor/backpack/crud/fields

# copy the blade file inside the folder we created above
cp -i vendor/afzalsabbir/toggle-field-for-backpack/src/resources/views/fields/toggle.blade.php resources/views/vendor/backpack/crud/fields/toggle.blade.php
```

**Step 2.** Remove the vendor namespace wherever you've used the field:

```
$this->crud->addField([
    'name' => 'agreed',
    'type' => 'toggle',
    'label' => 'I agree to the terms and conditions',
-   'view_namespace' => 'toggle-field-for-backpack::fields'
]);
```

**Step 3.** Uninstall this package. Since it only provides one file - `toggle.blade.php`, and you're no longer using that file, it makes no sense to have the package installed:

```
composer remove afzalsabbir/toggle-field-for-backpack
```

Change log
----------

[](#change-log)

Please see the [changelog](changelog.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [contributing.md](contributing.md) for details and a todolist.

Security
--------

[](#security)

If you discover any security related issues, please email [the author](composer.json) instead of using the issue tracker.

Credits
-------

[](#credits)

- [Adoptavia](https://github.com/adoptavia) - created the field type and shared it in [this thread](https://github.com/Laravel-Backpack/CRUD/issues/1724#issuecomment-441438326);
- [Cristian Tabacitu](https://github.com/tabacitu) - polish &amp; packaging;
- [All Contributors](../../contributors)

License
-------

[](#license)

MIT. Please see the [license file](license.md) for more information.

###  Health Score

21

—

LowBetter than 19% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity47

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

1415d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/fd5b67a41b67fbd3bfd88cdc9c5788cdd039fbb793964e348e2b64e807f6c16a?d=identicon)[afzalsabbir](/maintainers/afzalsabbir)

---

Top Contributors

[![AfzalSabbir](https://avatars.githubusercontent.com/u/39697431?v=4)](https://github.com/AfzalSabbir "AfzalSabbir (6 commits)")

---

Tags

laraveltoggleaddonadmin-panelbackpackBackpack for Laravel

### Embed Badge

![Health badge](/badges/afzalsabbir-toggle-field-for-backpack/health.svg)

```
[![Health](https://phpackages.com/badges/afzalsabbir-toggle-field-for-backpack/health.svg)](https://phpackages.com/packages/afzalsabbir-toggle-field-for-backpack)
```

###  Alternatives

[digitallyhappy/toggle-field-for-backpack

Easily toggle boolean attributes with a new field type.

2138.4k](/packages/digitallyhappy-toggle-field-for-backpack)[ziming/json-field-for-backpack

A Json Editor Field for Backpack

3597.3k](/packages/ziming-json-field-for-backpack)[izica/relations-widgets-for-backpack

Widgets for preview model relations in laravel backpack

2927.3k](/packages/izica-relations-widgets-for-backpack)[backpack/revise-operation

Backpack interface for venturecraft/revisionable

43279.9k1](/packages/backpack-revise-operation)[imokhles/signature-field-for-backpack

Easily add signature field to backpack admin panel.

262.0k](/packages/imokhles-signature-field-for-backpack)[soufiene-slimi/star-field-for-backpack

Easily rate items with stars using this new field type.

154.9k](/packages/soufiene-slimi-star-field-for-backpack)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
