edwardwestbury
edwardwestbury
FFilament
Created by edwardwestbury on 9/1/2023 in #❓┊help
Dynamically injecting content to MarkdownEditor fails
Hey All, I have a wizard with 2 steps, the first step contains a select to choose a markdown template, the second step has the content injected to the markdown editor, allowing to user to make minor edits if necessary. Running into issues attempting to push content to the Markdown component . This works fine the first time, but changing the selection and navigating back to the second step 2 things happen: 1) The content is not updated 2) Clicking into the Markdown Editor seems to inject "invisible" content and throws a JS error in markdown-editor.js Uncaught TypeError: i is undefined
Actions\Action::make('updateBlogContent')
->steps([
Step::make('markdown-template')
->schema([
FormComponents\Select::make('template')
->options(fn () => MarkdownTemplate::all()->pluck('name', 'id')->toArray())
->required()
->live()
->afterStateUpdated(function ($state, Set $set) {
$template = MarkdownTemplate::find($state);
$set('content', $template->content);
}),
]),
Step::make('blog-content')
->schema([
FormComponents\MarkdownEditor::make('content')
]),
]),
Actions\Action::make('updateBlogContent')
->steps([
Step::make('markdown-template')
->schema([
FormComponents\Select::make('template')
->options(fn () => MarkdownTemplate::all()->pluck('name', 'id')->toArray())
->required()
->live()
->afterStateUpdated(function ($state, Set $set) {
$template = MarkdownTemplate::find($state);
$set('content', $template->content);
}),
]),
Step::make('blog-content')
->schema([
FormComponents\MarkdownEditor::make('content')
]),
]),
I have tried adding ->live() to the MarkdownEditor, but no such luck. Any help is appreciated!
4 replies
FFilament
Created by edwardwestbury on 8/16/2023 in #❓┊help
FileUpload: Define custom url for getting uploaded files
In V2 there was a getUploadedFileUrlUsing() function within BaseFileUpload.php that seems to be missing in V3. I see the method getUploadedFileUsing() exists in V3 but I'm struggling to get it working by simply returning the URL like I could in V2. For context: These files are stored on custom disk on the local filesystem, but as they contain sensitive information I access them with a defined route which checks if the user is logged in and has valid permission. I'd like to be able to use this route, like I could in V2 with the getUploadedFileUrlUsing function. Any suggestions are much appreciated!
2 replies
FFilament
Created by edwardwestbury on 3/17/2023 in #❓┊help
How to close an ActionGroup dropdown with a custom action function
Is it possible to close the dropdown generated by an ActionGroup, when a custom function is called? Currently the dropdown will stay open after clicking on the action. I'm sure I'm missing something simple. Sample ViewRecord page below.
class ViewPost extends ViewRecord
{
protected static string $resource = PostResource::class;

protected function getActions(): array
{
return [
Actions\ActionGroup::make([
Actions\Action::make('publish-post')
->label('Publish blog post')
->action('publishPost'),
// other items ...
]),
];
}

public function publishPost()
{
$this->record->publish();

// hide the dropdown
}
}
class ViewPost extends ViewRecord
{
protected static string $resource = PostResource::class;

protected function getActions(): array
{
return [
Actions\ActionGroup::make([
Actions\Action::make('publish-post')
->label('Publish blog post')
->action('publishPost'),
// other items ...
]),
];
}

public function publishPost()
{
$this->record->publish();

// hide the dropdown
}
}
Any help is much appreciated!
3 replies