PHP code example of tapp / filament-form-builder

1. Go to this page and download the library: Download tapp/filament-form-builder 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/ */

    

tapp / filament-form-builder example snippets


use Tapp\FilamentFormBuilder\FilamentFormBuilderPlugin;

// In app/Providers/Filament/AdminPanelProvider.php
public function panel(Panel $panel): Panel
{
    return $panel
        // ...
        ->plugins([
            FilamentFormBuilderPlugin::make(),
            //...
        ]);
}

use Tapp\FilamentFormBuilder\FilamentFormBuilderGuestPlugin;

// In app/Providers/Filament/GuestPanelProvider.php
public function panel(Panel $panel): Panel
{
    return $panel
        // ...
        ->plugins([
            FilamentFormBuilderGuestPlugin::make(),
            //...
        ]);
}

use Tapp\FilamentFormBuilder\FilamentFormBuilderFrontendPlugin;

// In app/Providers/Filament/AppPanelProvider.php
public function panel(Panel $panel): Panel
{
    return $panel
        // ...
        ->plugins([
            FilamentFormBuilderFrontendPlugin::make(),
            //...
        ]);
}

   // e.g. app/Policies/FilamentFormPolicy.php
   public function viewEntries(User $user, FilamentForm $form): bool
   {
       if (! (bool) $form->private_entries) {
           return true;
       }
       return $user->hasRole('Admin'); // or your own rules
   }
   

   if ($entry->filamentForm && (bool) $entry->filamentForm->private_entries) {
       return $user->can('viewEntries', $entry->filamentForm);
   }
   

'tenancy' => [
    // Enable tenancy support
    'enabled' => true,

    // The Tenant model class
    'model' => \App\Models\Team::class,

    // Optional: Override the tenant relationship name
    // (defaults to snake_case of tenant model class name: Team -> 'team')
    'relationship_name' => null,

    // Optional: Override the tenant foreign key column name
    // (defaults to relationship_name + '_id': 'team' -> 'team_id')
    'column' => null,
],

use Filament\Panel;
use App\Models\Team;
use Tapp\FilamentFormBuilder\FilamentFormBuilderPlugin;

public function panel(Panel $panel): Panel
{
    return $panel
        ->tenant(Team::class)
        ->plugins([
            FilamentFormBuilderPlugin::make(),
        ]);
}

'tenancy' => [
    'enabled' => false,
    'model' => null,
],

// In your EventServiceProvider.php
protected $listen = [
    \Tapp\FilamentFormBuilder\Events\EntrySaved::class => [
        \App\Listeners\HandleFormSubmission::class,
    ],
];

// Create a listener class
namespace App\Listeners;

use Tapp\FilamentFormBuilder\Events\EntrySaved;

class HandleFormSubmission
{
    public function handle(EntrySaved $event): void
    {
        // Access the form entry
        $entry = $event->entry;
        
        // Perform actions with the form data
        // For example, send notifications, update other records, etc.
    }
}
bash
php artisan vendor:publish --tag="filament-form-builder-migrations"
bash
php artisan migrate
bash
php artisan vendor:publish --tag="filament-form-builder-views"
bash
php artisan vendor:publish --tag="filament-form-builder-config"
bash
php artisan vendor:publish --tag="filament-form-builder-config"

    content: [
        ...
        "./vendor/tapp/**/*.blade.php",
    ],

    @livewire('tapp.filament-form-builder.livewire.filament-form.show', ['form' => $test->form, 'blockRedirect' => true])