daan5964
daan5964
FFilament
Created by daan5964 on 2/9/2024 in #❓┊help
Challenges with Implementing EditAction in Multi-step Process: Modal
Hey everyone, I'm currently working on implementing an EditAction on a Widget in multiple steps, and I've hit a bit of a roadblock. Specifically, in step two, I'm aiming to overwrite some_row with new information loaded from an external API. The catch is that I want this new data to be displayed in the model so that users can edit it. Upon saving, the updated information should then be stored in the table. I've tried a couple of approaches, but each has its own limitation: - Using ->default(): The loaded data doesn't show up in the modal. - Using $set closure: I can update the data, but it's not editable by the user. Furthermore, any value entered by the user in the modal doesn't affect what gets saved using the $set closure. Here's the relevant code snippet from the second step:
Step::make('Step two') ->schema(function (Get $get, Set $set, DataService $dataService, $record) { // $set doesn't work, as the value cannot be updated by the user return [ TextInput::make('some_row') ->label('some row') ->default($dataService->getValue($record)), ]; });
2 replies
FFilament
Created by daan5964 on 2/6/2024 in #❓┊help
Update information of the explanation field based on the Code given (real time)
Hi everyone. I am building a model that allows an user to update an code. when live editing this code and pressing a button I want to load some explanation/data before the user can save this. So I was wondering how can I modify the second field based on the data in the first one when the example button is pressed? For example: 1 -> The user adds an code 2 -> Presses the example button 3 -> The information in the Explanation field is updated (not saved yet). I started with something like this (screenshot for what I want is below): EditAction::make() ->form([ TextInput::make('code_one') ->required() ->numeric() ->minValue(1000000000) ->maxValue(9999999999), // Below need to be updated based on an action (but not yet saved) TextInput::make('explanation') ->readOnly() ])->modalContent( // Show some information fn($record) => \view('filament.resources.data.modals.some-info', ['item' => $record] )) ->extraModalFooterActions(fn (Action $action): array => [ // This is incorrect $action->makeModalSubmitAction('Example ', arguments: ['another' => false]), ])->action(function (array $data, array $arguments) { }) ),
3 replies
FFilament
Created by daan5964 on 1/25/2024 in #❓┊help
Enhancing Error Handling in Laravel-Excel Integration with FilementPHP
Hi, We are attempting to import data from an excel file using FilementPHP via https://laravel-excel.com and display multiple error messages in the interface. However, the Laravel fail closure only provides the option to pass a single error for validation when self-defined. Is it feasible to show multiple errors that can subsequently be displayed?
class SomeRule implements ValidationRule
{
public function validate(string $attribute, mixed $value, \Closure $fail): void
{
try {
Importer::fromArray(Excel::toArray(new Validate(), $value));
} catch (ValidationException $exception) {
$fail(implode(',', collect($exception->errors())->first()));
} catch (NoTypeDetectedException|InvalidArgumentException $exception) {
$fail($exception->getMessage()) <-- only allow one error;
}
}
}
class SomeRule implements ValidationRule
{
public function validate(string $attribute, mixed $value, \Closure $fail): void
{
try {
Importer::fromArray(Excel::toArray(new Validate(), $value));
} catch (ValidationException $exception) {
$fail(implode(',', collect($exception->errors())->first()));
} catch (NoTypeDetectedException|InvalidArgumentException $exception) {
$fail($exception->getMessage()) <-- only allow one error;
}
}
}
3 replies
FFilament
Created by daan5964 on 12/13/2023 in #❓┊help
Modal File Upload for Widget Buttons
I'm developing a board with multiple widgets, including tables. One widget links to a resource where users can upload files and metadata on a new page. I'm exploring the possibility of creating a button that opens a modal for the same purpose within the widget. While the button exists, it's uncertain if it can be linked to an action that opens a modal.
5 replies
FFilament
Created by daan5964 on 12/12/2023 in #❓┊help
Changing FilementPHP Header Colors: Can You Hack the Vendor Folder and Tweak That Topbar?
No description
10 replies