Skip to content

Commit

Permalink
Use Request ParameterBag
Browse files Browse the repository at this point in the history
  • Loading branch information
francoism90 authored Sep 27, 2024
1 parent d2326e3 commit f76a53d
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/Support/Html/Mixins/HtmlExtendedMixin.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,12 @@
use Spatie\Html\Elements\Form;
use stdClass;

#[\AllowDynamicProperties]
class HtmlExtendedMixin extends stdClass
{
protected ?Livewire $form = null;

public function wireForm(): mixed
{
return function (Livewire $form, ?string $action = null): Form {
$this->form = $form;
$this->request->attributes->set('form', $form);

return Form::create()
->attributeIf($action, 'wire:submit', $action);
Expand All @@ -26,7 +23,7 @@ public function wireForm(): mixed
public function closeWireForm(): mixed
{
return function (): Form {
$this->form = null;
$this->request->attributes->remove('form');

return Form::create()->close();
};
Expand All @@ -35,7 +32,7 @@ public function closeWireForm(): mixed
public function error(): mixed
{
return function (string $field, ?string $message = null, ?string $format = null): Validate {
$messageBag = $this->form?->getComponent()->getErrorBag();
$messageBag = $this->request->get('form')?->getComponent()->getErrorBag();

$hasMessage = $messageBag?->has($field) ?? false;

Expand Down

0 comments on commit f76a53d

Please sign in to comment.