Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent submit form on enter #429

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions app/Concerns/PreventSubmitFormOnEnter.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

declare(strict_types=1);

namespace App\Concerns;

use Filament\Actions\Action;

trait PreventSubmitFormOnEnter
{
protected function getCreateFormAction(): Action
{
return parent::getCreateFormAction()->extraAttributes(['type' => 'button', 'wire:click' => 'create']);
}

protected function getSaveFormAction(): Action
{
return parent::getSaveFormAction()->extraAttributes(['type' => 'button', 'wire:click' => 'save']);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@
namespace App\Filament\Admin\Resources\BenefitResource\Pages;

use App\Concerns\PreventMultipleSubmit;
use App\Concerns\PreventSubmitFormOnEnter;
use App\Filament\Admin\Resources\BenefitResource;
use Filament\Resources\Pages\CreateRecord;
use Illuminate\Contracts\Support\Htmlable;

class CreateBenefit extends CreateRecord
{
use PreventMultipleSubmit;
use PreventSubmitFormOnEnter;

protected static string $resource = BenefitResource::class;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace App\Filament\Admin\Resources\InstitutionResource\Pages;

use App\Concerns\PreventMultipleSubmit;
use App\Concerns\PreventSubmitFormOnEnter;
use App\Filament\Admin\Resources\InstitutionResource;
use App\Filament\Admin\Resources\UserInstitutionResource\Pages\EditUserInstitution;
use App\Forms\Components\Repeater;
Expand All @@ -19,6 +20,7 @@ class CreateInstitution extends CreateRecord
{
use HasWizard;
use PreventMultipleSubmit;
use PreventSubmitFormOnEnter;

protected static string $resource = InstitutionResource::class;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@
namespace App\Filament\Admin\Resources\OrganizationResource\Pages;

use App\Concerns\PreventMultipleSubmit;
use App\Concerns\PreventSubmitFormOnEnter;
use App\Filament\Admin\Resources\OrganizationResource;
use Filament\Resources\Pages\CreateRecord;

class CreateOrganization extends CreateRecord
{
use PreventMultipleSubmit;
use PreventSubmitFormOnEnter;

protected static string $resource = OrganizationResource::class;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@
namespace App\Filament\Admin\Resources\ResultResource\Pages;

use App\Concerns\PreventMultipleSubmit;
use App\Concerns\PreventSubmitFormOnEnter;
use App\Filament\Admin\Resources\ResultResource;
use Filament\Resources\Pages\CreateRecord;
use Illuminate\Contracts\Support\Htmlable;

class CreateResult extends CreateRecord
{
use PreventMultipleSubmit;
use PreventSubmitFormOnEnter;

protected static string $resource = ResultResource::class;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@
namespace App\Filament\Admin\Resources\RoleResource\Pages;

use App\Concerns\PreventMultipleSubmit;
use App\Concerns\PreventSubmitFormOnEnter;
use App\Filament\Admin\Resources\RoleResource;
use Filament\Resources\Pages\CreateRecord;
use Illuminate\Contracts\Support\Htmlable;

class CreateRole extends CreateRecord
{
use PreventMultipleSubmit;
use PreventSubmitFormOnEnter;

protected static string $resource = RoleResource::class;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@
namespace App\Filament\Admin\Resources\ServiceResource\Pages;

use App\Concerns\PreventMultipleSubmit;
use App\Concerns\PreventSubmitFormOnEnter;
use App\Filament\Admin\Resources\ServiceResource;
use Filament\Resources\Pages\CreateRecord;
use Illuminate\Contracts\Support\Htmlable;

class CreateService extends CreateRecord
{
use PreventMultipleSubmit;
use PreventSubmitFormOnEnter;

protected static string $resource = ServiceResource::class;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace App\Filament\Admin\Resources\UserInstitutionResource\Pages;

use App\Concerns\HasParentResource;
use App\Concerns\PreventSubmitFormOnEnter;
use App\Filament\Admin\Resources\InstitutionResource;
use App\Filament\Admin\Resources\UserInstitutionResource;
use Filament\Forms\Components\Section;
Expand All @@ -16,6 +17,7 @@
class EditUserInstitution extends EditRecord
{
use HasParentResource;
use PreventSubmitFormOnEnter;

protected static string $resource = UserInstitutionResource::class;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@
namespace App\Filament\Admin\Resources\UserResource\Pages;

use App\Concerns\PreventMultipleSubmit;
use App\Concerns\PreventSubmitFormOnEnter;
use App\Filament\Admin\Resources\UserResource;
use Filament\Resources\Pages\CreateRecord;

class CreateUser extends CreateRecord
{
use PreventMultipleSubmit;
use PreventSubmitFormOnEnter;

protected static string $resource = UserResource::class;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@
namespace App\Filament\Organizations\Resources\BeneficiaryInterventionResource\Pages;

use App\Concerns\PreventMultipleSubmit;
use App\Concerns\PreventSubmitFormOnEnter;
use App\Filament\Organizations\Resources\BeneficiaryInterventionResource;
use Filament\Resources\Pages\CreateRecord;

class CreateBeneficiaryIntervention extends CreateRecord
{
use PreventMultipleSubmit;
use PreventSubmitFormOnEnter;

protected static string $resource = BeneficiaryInterventionResource::class;
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace App\Filament\Organizations\Resources\BeneficiaryResource\Pages\CloseFile;

use App\Concerns\PreventMultipleSubmit;
use App\Concerns\PreventSubmitFormOnEnter;
use App\Filament\Organizations\Resources\BeneficiaryResource;
use App\Models\Specialist;
use App\Services\Breadcrumb\BeneficiaryBreadcrumb;
Expand All @@ -20,6 +21,7 @@ class CreateCloseFile extends EditRecord
{
use HasWizard;
use PreventMultipleSubmit;
use PreventSubmitFormOnEnter;

protected static string $resource = BeneficiaryResource::class;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace App\Filament\Organizations\Resources\BeneficiaryResource\Pages;

use App\Concerns\PreventMultipleSubmit;
use App\Concerns\PreventSubmitFormOnEnter;
use App\Enums\AddressType;
use App\Filament\Organizations\Resources\BeneficiaryResource;
use App\Forms\Components\Notice;
Expand Down Expand Up @@ -37,6 +38,7 @@ class CreateBeneficiary extends CreateRecord
{
use HasWizard;
use PreventMultipleSubmit;
use PreventSubmitFormOnEnter;

protected static string $resource = BeneficiaryResource::class;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace App\Filament\Organizations\Resources\BeneficiaryResource\Pages\DetailedEvaluation;

use App\Concerns\PreventMultipleSubmit;
use App\Concerns\PreventSubmitFormOnEnter;
use App\Filament\Organizations\Resources\BeneficiaryResource;
use App\Models\BeneficiaryPartner;
use App\Services\Breadcrumb\BeneficiaryBreadcrumb;
Expand All @@ -17,6 +18,7 @@ class CreateDetailedEvaluation extends EditRecord
{
use HasWizard;
use PreventMultipleSubmit;
use PreventSubmitFormOnEnter;

protected static string $resource = BeneficiaryResource::class;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace App\Filament\Organizations\Resources\BeneficiaryResource\Pages\InitialEvaluation;

use App\Concerns\PreventMultipleSubmit;
use App\Concerns\PreventSubmitFormOnEnter;
use App\Filament\Organizations\Resources\BeneficiaryResource;
use App\Services\Breadcrumb\BeneficiaryBreadcrumb;
use Filament\Forms\Components\Wizard\Step;
Expand All @@ -16,6 +17,7 @@ class CreateInitialEvaluation extends EditRecord
{
use HasWizard;
use PreventMultipleSubmit;
use PreventSubmitFormOnEnter;

protected static string $resource = BeneficiaryResource::class;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@

namespace App\Filament\Organizations\Resources\InterventionPlanResource\Pages;

use App\Concerns\PreventSubmitFormOnEnter;
use App\Filament\Organizations\Resources\InterventionPlanResource;
use Filament\Resources\Pages\CreateRecord;

class CreateInterventionPlan extends CreateRecord
{
use PreventSubmitFormOnEnter;

protected static string $resource = InterventionPlanResource::class;
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use App\Concerns\HasParentResource;
use App\Concerns\PreventMultipleSubmit;
use App\Concerns\PreventSubmitFormOnEnter;
use App\Filament\Organizations\Resources\MonitoringResource;
use App\Models\Monitoring;
use App\Models\Specialist;
Expand All @@ -24,6 +25,7 @@ class CreateMonitoring extends CreateRecord
use HasWizard;
use HasParentResource;
use PreventMultipleSubmit;
use PreventSubmitFormOnEnter;

protected static string $resource = MonitoringResource::class;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@
namespace App\Filament\Organizations\Resources\ServiceResource\Pages;

use App\Concerns\PreventMultipleSubmit;
use App\Concerns\PreventSubmitFormOnEnter;
use App\Filament\Organizations\Resources\ServiceResource;
use Filament\Resources\Pages\CreateRecord;
use Illuminate\Contracts\Support\Htmlable;

class CreateService extends CreateRecord
{
use PreventMultipleSubmit;
use PreventSubmitFormOnEnter;

protected static string $resource = ServiceResource::class;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace App\Filament\Organizations\Resources\UserResource\Pages;

use App\Concerns\PreventMultipleSubmit;
use App\Concerns\PreventSubmitFormOnEnter;
use App\Filament\Organizations\Resources\UserResource;
use App\Models\User;
use Filament\Facades\Filament;
Expand All @@ -15,6 +16,7 @@
class CreateUser extends CreateRecord
{
use PreventMultipleSubmit;
use PreventSubmitFormOnEnter;

protected static string $resource = UserResource::class;

Expand Down
Loading