PHP code example of chanthoeun / filament-custom-forms

1. Go to this page and download the library: Download chanthoeun/filament-custom-forms library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

chanthoeun / filament-custom-forms example snippets


use Chanthoeun\FilamentCustomForms\CustomFormPlugin;

public function panel(Panel $panel): Panel
{
    return $panel
        ->plugin(
            CustomFormPlugin::make()
                ->navigationGroup('Form Builder')
                ->navigationFormIcon('heroicon-o-document-duplicate')
                ->navigationEntryIcon('heroicon-o-clipboard-document-list')
                ->panelAccess(true)  // Optional: Enable granular panel access controls
                ->translations(true) // Optional: Enable spatie/laravel-translatable fields
        );
}

namespace App\Enums;

use Filament\Support\Contracts\HasLabel;
use Chanthoeun\FilamentCustomForms\Contracts\IsFormOption;

enum Gender: string implements HasLabel, IsFormOption
{
    case Male = 'male';
    case Female = 'female';
    
    public function getLabel(): ?string
    {
        return match ($this) {
            self::Male => __('Male'),
            self::Female => __('Female'),
        };
    }
}

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Chanthoeun\FilamentCustomForms\Contracts\IsFormOption;

class Province extends Model implements IsFormOption
{
    protected $fillable = ['name'];
}
bash
php artisan vendor:publish --tag="filament-custom-forms-config"
php artisan vendor:publish --tag="filament-custom-forms-migrations"
bash
php artisan migrate
bash
php artisan migrate