F
Filament6d ago
Cem

Help with form outside Panel

I'm learning Filament / Laravel so apologies if it's a stupid question. I have bought the minimal theme; works great within the Panels but i want to create a simple page with just the form. The form displays nicely but i'm missing some scripts Here's my controller

<?php

namespace App\Http\Controllers;

use Filament\MinimalTheme;
use Illuminate\View\View;

class PublicAnamneseController extends Controller
{
public function create(): View
{
MinimalTheme::make();
return view('anamnese.create');
}
}

<?php

namespace App\Http\Controllers;

use Filament\MinimalTheme;
use Illuminate\View\View;

class PublicAnamneseController extends Controller
{
public function create(): View
{
MinimalTheme::make();
return view('anamnese.create');
}
}
The view:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Anamnese Form</title>
@filamentStyles
@vite('resources/css/app.css')
@livewireStyles
</head>
<body class="bg-white">
<div class="min-h-screen max-w-7xl mx-auto px-4 py-12">
<div class="max-w-6xl mx-auto px-6 py-8">
<livewire:public-anamnese-form/>
</div>
</div>
@livewireScripts
@filamentScripts
@vite('resources/js/app.js')
</body>
</html>

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Anamnese Form</title>
@filamentStyles
@vite('resources/css/app.css')
@livewireStyles
</head>
<body class="bg-white">
<div class="min-h-screen max-w-7xl mx-auto px-4 py-12">
<div class="max-w-6xl mx-auto px-6 py-8">
<livewire:public-anamnese-form/>
</div>
</div>
@livewireScripts
@filamentScripts
@vite('resources/js/app.js')
</body>
</html>
and the service provider

<?php

namespace App\Providers;

use Illuminate\Support\ServiceProvider;
use Livewire\Livewire;

class AppServiceProvider extends ServiceProvider
{
/**
* Register any application services.
*/
public function register(): void
{
//
}

/**
* Bootstrap any application services.
*/
public function boot(): void
{
Livewire::component('public-anamnese-form', \App\Livewire\PublicAnamneseForm::class);
}
}

<?php

namespace App\Providers;

use Illuminate\Support\ServiceProvider;
use Livewire\Livewire;

class AppServiceProvider extends ServiceProvider
{
/**
* Register any application services.
*/
public function register(): void
{
//
}

/**
* Bootstrap any application services.
*/
public function boot(): void
{
Livewire::component('public-anamnese-form', \App\Livewire\PublicAnamneseForm::class);
}
}
No description
10 Replies
Cem
CemOP6d ago
import defaultTheme from 'tailwindcss/defaultTheme';
import preset from './vendor/filament/support/tailwind.config.preset'

/** @type {import('tailwindcss').Config} */
export default {
presets: [preset],
content: [
'./vendor/laravel/framework/src/Illuminate/Pagination/resources/views/*.blade.php',
'./storage/framework/views/*.php',
'node_modules/preline/dist/*.js',
'./resources/**/*.blade.php',
'./resources/**/*.js',
'./resources/**/*.vue',
],
theme: {
extend: {
fontFamily: {
sans: ['InterVariable', ...defaultTheme.fontFamily.sans],
},
},
},
plugins: [
'preline/plugin',
],
};
import defaultTheme from 'tailwindcss/defaultTheme';
import preset from './vendor/filament/support/tailwind.config.preset'

/** @type {import('tailwindcss').Config} */
export default {
presets: [preset],
content: [
'./vendor/laravel/framework/src/Illuminate/Pagination/resources/views/*.blade.php',
'./storage/framework/views/*.php',
'node_modules/preline/dist/*.js',
'./resources/**/*.blade.php',
'./resources/**/*.js',
'./resources/**/*.vue',
],
theme: {
extend: {
fontFamily: {
sans: ['InterVariable', ...defaultTheme.fontFamily.sans],
},
},
},
plugins: [
'preline/plugin',
],
};
LeandroFerreira
what about PublicAnamneseForm component?
Cem
CemOP6d ago
<?php

namespace App\Livewire;

use App\Filament\Resources\AnamneseResource;
use App\Models\Anamnese;
use Livewire\Component;
use Filament\Forms\Concerns\InteractsWithForms;
use Filament\Forms\Contracts\HasForms;
use Filament\Forms\Form;

class PublicAnamneseForm extends Component implements HasForms
{
use InteractsWithForms;

public ?array $data = [];

public function mount(): void
{
$this->form->fill();
}

public function form(Form $form): Form
{
return AnamneseResource::form($form);
}

public function create(): void
{
$data = $this->form->getState();
$anamnese = Anamnese::create($data);
$this->form->fill();
session()->flash('success', 'Form submitted successfully!');
}

public function render()
{
return view('livewire.public-anamnese-form');
}
}
<?php

namespace App\Livewire;

use App\Filament\Resources\AnamneseResource;
use App\Models\Anamnese;
use Livewire\Component;
use Filament\Forms\Concerns\InteractsWithForms;
use Filament\Forms\Contracts\HasForms;
use Filament\Forms\Form;

class PublicAnamneseForm extends Component implements HasForms
{
use InteractsWithForms;

public ?array $data = [];

public function mount(): void
{
$this->form->fill();
}

public function form(Form $form): Form
{
return AnamneseResource::form($form);
}

public function create(): void
{
$data = $this->form->getState();
$anamnese = Anamnese::create($data);
$this->form->fill();
session()->flash('success', 'Form submitted successfully!');
}

public function render()
{
return view('livewire.public-anamnese-form');
}
}
@LeandroFerreira sorry forgot that one should I be adding fields in the $data array or something ?
Cem
CemOP6d ago
@LeandroFerreira Genius ! That was it !
Cem
CemOP6d ago
No description
Cem
CemOP6d ago
Donw to one error now but i guess has nothing to do with it
LeandroFerreira
yes, you need to verify where is it..
Cem
CemOP6d ago
Somewhat points to
No description
Cem
CemOP6d ago
but i'll dig that one too. Thank you very much for your help; i wouldn't find it !
Want results from more Discord servers?
Add your server