F
Filament2mo ago
erena

Lost in docs

Hi, I am totally new to filament and livewire but I have a little bit of experience in Laravel. I am just trying to learn filament v4 by creating a project, but the docs are seemed not-so-helpfull. I'm currently trying to add a form to a custom page, but I do not even understand where to put my code. Even if I simply copy-paste the code I saw in web, an error occurs. Am I looking at the wrong page for learning this (https://filamentphp.com/docs/4.x/navigation/custom-pages) ? Or should I start with Livewire documents? Sorry for poor english and thanks in advance.
<?php

namespace App\Filament\Pages;

use Filament\Pages\Page;
use Illuminate\Support\Facades\Auth;
use BackedEnum;
use Filament\Schemas\Schema;
use Filament\Forms\Components\TextInput;

class Settings extends Page
{
protected string $view = 'filament.pages.settings';

protected static ?string $navigationLabel = '//';
protected static ?string $title = '//';
protected ?string $subheading = '//';

protected static string|BackedEnum|null $navigationIcon = 'heroicon-s-wrench-screwdriver';

public static function canAccess(): bool
{
return !empty(Auth::user()->organization_id);
}

public function myCustomFunction(): Schema
{
// Should I put my code here and return a Schema object?

$schema = new Schema();
return $schema
->components([
TextInput::make('name')
->label("test")
->required()
]);

}

}
<?php

namespace App\Filament\Pages;

use Filament\Pages\Page;
use Illuminate\Support\Facades\Auth;
use BackedEnum;
use Filament\Schemas\Schema;
use Filament\Forms\Components\TextInput;

class Settings extends Page
{
protected string $view = 'filament.pages.settings';

protected static ?string $navigationLabel = '//';
protected static ?string $title = '//';
protected ?string $subheading = '//';

protected static string|BackedEnum|null $navigationIcon = 'heroicon-s-wrench-screwdriver';

public static function canAccess(): bool
{
return !empty(Auth::user()->organization_id);
}

public function myCustomFunction(): Schema
{
// Should I put my code here and return a Schema object?

$schema = new Schema();
return $schema
->components([
TextInput::make('name')
->label("test")
->required()
]);

}

}
<x-filament-panels::page>
{{ $this->myCustomFunction() }}
</x-filament-panels::page>
<x-filament-panels::page>
{{ $this->myCustomFunction() }}
</x-filament-panels::page>
This does not work, as you can guess. I just don't know where to look for fixing this.
Solution:
Pages are livewire components. You can use this section to add a form to the page
Jump to solution
2 Replies
Solution
LeandroFerreira
LeandroFerreira2mo ago
Pages are livewire components. You can use this section to add a form to the page
erena
erenaOP2mo ago
Thanks a lot for helping!

Did you find this page helpful?