mikeybelike/intl-tel-input-backpack

A backpack field package for formatting and inputting international telephone numbers

0.3.0 2024-01-21 04:39 UTC

This package is auto-updated.

Last update: 2024-04-21 05:13:50 UTC


README

Latest Version on Packagist Total Downloads The Whole Fruit Manifesto

This package provides you the ability to enter and validate international telephone numbers for projects that use the Backpack for Laravel administration panel.

More exactly, it adds the intl-tel-input plugin to your Backpack CRUD interfaces as a field so you can easily input valid interational telephone numbers.

Screenshots

Backpack Intl Tel Input Addon

Installation

Via Composer

composer require mikeybelike/intl-tel-input-backpack

Usage

To use the field this package provides, inside your custom CrudController do:

$this->crud->addField([
    'name' => 'contact_number',
    'label' => 'Contact Number',
    'type' => 'intl-tel-input',
    'view_namespace' => 'mikeybelike.intl-tel-input-backpack::fields',

    // additional optional configuration supported
    'options' => [
        'initialCountry' => 'gb'
    ]
]);

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

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/mikeybelike/intl-tel-input-backpack/src/resources/views/fields/field_name.blade.php resources/views/vendor/backpack/crud/fields/field_name.blade.php

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

$this->crud->addField([
    'name' => 'contact_number',
    'type' => 'intl-tel-input',
    'label' => 'Contact Number',
-   'view_namespace' => 'mikeybelike.intl-tel-input-backpack::fields'
]);

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

composer remove mikeybelike/intl-tel-input-backpack

Change log

Changes are documented here on Github. Please see the Releases tab.

Testing

composer test

Contributing

Please see contributing.md for a todolist and howtos.

Security

If you discover any security related issues, please email hi@mikey.dev instead of using the issue tracker.

Credits

License

This project was released under MIT, so you can install it on top of any Backpack & Laravel project. Please see the license file for more information.

However, please note that you do need Backpack installed, so you need to also abide by its YUMMY License. That means in production you'll need a Backpack license code. You can get a free one for non-commercial use (or a paid one for commercial use) on backpackforlaravel.com.