DEV Community

Cover image for Customizing Action Buttons in Laravel Orchid CRUD: Removing Labels and Adding a Delete Button
Asif Sheikh
Asif Sheikh

Posted on

Customizing Action Buttons in Laravel Orchid CRUD: Removing Labels and Adding a Delete Button

Hello everyone,

I’m currently working on a project using the Laravel Orchid CRUD package. Specifically, I’m trying to customize the action buttons for an Inquiry Resource in the CRUD implementation.

What I’m Trying to Achieve
Remove the labels from the action buttons (e.g., Edit, Delete, etc.) to make them appear as icons only.
Add a Delete button to the action buttons, as it’s currently missing in the default configuration.
What I Have Tried
I’ve been exploring the Orchid documentation and related resources to find a solution for customizing the actions, but I haven’t been able to find a clear way to achieve these goals. My resource class follows the standard structure as outlined in the Orchid CRUD documentation.

Here is the relevant portion of my Inquiry Resource code:

namespace App\Orchid\Resources;

use App\Models\Inquiry;
use Orchid\Crud\Resource;
use Orchid\Screen\Actions\Button;
use Orchid\Screen\Fields\Input;
use Orchid\Screen\TD;

class InquiryResource extends Resource
{
    public static $model = Inquiry::class;

    public function fields(): array
    {
        return [
            Input::make('name')->title('Name')->required(),
            Input::make('email')->title('Email')->required(),
        ];
    }

    public function columns(): array
    {
        return [
            TD::make('name', 'Name'),
            TD::make('email', 'Email'),
        ];
    }

    public function actions(): array
    {
        return [
            Button::make('Edit')
                ->icon('pencil')
                ->method('edit'),
        ];
    }
}
Enter fullscreen mode Exit fullscreen mode

Challenges
I cannot find a way to remove the labels from the action buttons while keeping the icons intact.
I’m unsure how to properly define a Delete button for this resource.

Question
Could someone guide me on how to:

Remove the labels from the action buttons and display only the icons?
Add a Delete button to the action buttons?
Any help or examples would be greatly appreciated! Thank you in advance.

Best regards,

Thanks for read this article.😊🥰
If you have any queries related to this article, please🙏 drop query in this comment section. We will reply as soon as possible on your query.

Top comments (0)