mahmoud-mosaad/backpack-fields

Adds custom fields which useful for certain purposes to Backpack Laravel.

dev-master 2021-10-22 13:03 UTC

This package is auto-updated.

Last update: 2024-05-22 18:26:53 UTC


README

Latest Version on Packagist Total Downloads

This package provides custom fields type for the Backpack for Laravel administration panel. The _toggle fields allows admins to toggle another fields as dependency, in a prettier way. The _array_ajax fields adds select from array not relationships only

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 fields 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

Select From Array Toggle

Installation

Via Composer

composer require mahmoud-mosaad/backpack-fields

Usage

Inside your custom CrudController:

$this->crud->addField([
    'name' => 'from_place',
    'type'  => 'select_from_array_toggle',
    'label' => 'From Places',
    'options' => [
        1 => 'First',
        2 => 'Second',
        3 => 'Third',
        4 => 'Fourth',
        100 => 'Other',
    ],
    'allows_null' => false,
    'show_when' => [
        100 => [
            'from_place_other'
        ]
    ],
]);

$this->crud->addField([
    'name' => 'from_place_other',
    'label' => trans('backpack::base.other'),
    'type' => 'text',
]);

Publish Views. Copy-paste the blades to your directory:

# Publish Vendor Views to resources (Win CMD)
xcopy .\vendor\mahmoud-mosaad\backpack-fields\src\resources\views\crud\fields .\resources\views\vendor\backpack\crud\fields\

# Publish Vendor Views to resources (Bash)
cp .\vendor\mahmoud-mosaad\backpack-fields\src\resources\views\crud\fields .\resources\views\vendor\backpack\crud\fields\

Uninstall this package. Since it only provides fields you already published and you're no longer using those files, it makes no sense to have the package installed:

composer remove mahmoud-mosaad/backpack-fields

Credits

License

MIT. Please see the license file for more information.