F
Filament•13mo ago
zoomZoom

Actions : disabled() and hidden() are the same

public function editAction()
{
return Action::make('edit')
->icon('heroicon-m-pencil-square')
// ->iconButton()
->mountUsing(function (array $arguments, Form $form) {
$this->article = ArticleModel::find($arguments['articleId']);
// $form->fill($this->article->toArray());
$form->fill([
'title' => $this->article->title,
]);
})
->form([
TextInput::make('title')
->label('Titre')
->required(),
])
->action(function (array $data): void {
$this->article->update($data);
})->hidden(true);
}
public function editAction()
{
return Action::make('edit')
->icon('heroicon-m-pencil-square')
// ->iconButton()
->mountUsing(function (array $arguments, Form $form) {
$this->article = ArticleModel::find($arguments['articleId']);
// $form->fill($this->article->toArray());
$form->fill([
'title' => $this->article->title,
]);
})
->form([
TextInput::make('title')
->label('Titre')
->required(),
])
->action(function (array $data): void {
$this->article->update($data);
})->hidden(true);
}
<div> {{ ($this->editAction)(['articleId' => $article->id]) }} </div>
<div> {{ ($this->editAction)(['articleId' => $article->id]) }} </div>
If i do hidden(true) the result is the same as disabled() . The button is there but not clickable. Is this the wanted behavior ? I thought hidden meant not visible ? Have a good day ! 🚀
No description
7 Replies
zoomZoom
zoomZoomOP•13mo ago
bumping this thread
jaocero
jaocero•13mo ago
Bumping this as I encounter this
ChesterS
ChesterS•13mo ago
hmm this is the 3rd post with this and I can reproduce it too. The hidden seems to work if it's in an action group, but not when it's by itself. This is weird Ok so I had a look at the code and, unless I'm missing something, the isHidden() method is not used anywhere. You probably have to do it manually like this
<div>
@if($this->editAction->isVisible() )
{{ ($this->editAction)(['articleId' => $article->id]) }}
@endif
</div>
<div>
@if($this->editAction->isVisible() )
{{ ($this->editAction)(['articleId' => $article->id]) }}
@endif
</div>
Jon Mason
Jon Mason•10mo ago
I tried doing it using a conditional in my blade file, and I didn't have any luck in my specific situation. Is this a bug?
awcodes
awcodes•10mo ago
I do think it’s weird though. Using hidden. IMHO should keep it from rendering, since most people aren’t using actions in rendered livewire views.
Jon Mason
Jon Mason•10mo ago
In my use case, I have a "submit" button and a "reopen" button. I was hoping to have the submit button visible when the form hadn't been submitted, and the re-open button visible when it had. Regardless of using hidden/visible attributes, it still just disables/enables. That seems like the wrong behavior. I posted about it here:https://discord.com/channels/883083792112300104/1201257018577649664
Want results from more Discord servers?
Add your server