can i create a form in app/Filament/Pages/CreateModelname.php?
A form which i use only to create a record?
i tried:
but does not work.
<?php
namespace App\Filament\Resources\AvailabilityResource\Pages;
use App\Filament\Resources\AvailabilityResource;
use Filament\Resources\Pages\CreateRecord;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\DateTimePicker;
use App\Models\ReservableItem;
class CreateAvailability extends CreateRecord
{
public static $resource = AvailabilityResource::class;
public function form()
{
return parent::form()->schema([
Select::make('reservable_item_id')
->label('Reservable Item')
->options(
ReservableItem::all()->pluck('id', 'name')->toArray()
)
->placeholder('Select an Item'),
DateTimePicker::make('start_time')
->label('Start Time')
->withTimezone()
->required(),
// add other fields as necessary
]);
}
}
<?php
namespace App\Filament\Resources\AvailabilityResource\Pages;
use App\Filament\Resources\AvailabilityResource;
use Filament\Resources\Pages\CreateRecord;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\DateTimePicker;
use App\Models\ReservableItem;
class CreateAvailability extends CreateRecord
{
public static $resource = AvailabilityResource::class;
public function form()
{
return parent::form()->schema([
Select::make('reservable_item_id')
->label('Reservable Item')
->options(
ReservableItem::all()->pluck('id', 'name')->toArray()
)
->placeholder('Select an Item'),
DateTimePicker::make('start_time')
->label('Start Time')
->withTimezone()
->required(),
// add other fields as necessary
]);
}
}
2 Replies
Isn't there a method
getFormSchema
?Thanks @bytexr ! Great π