Skip to content

Commit

Permalink
LWB-264 Adjusting type logic for the Button Component
Browse files Browse the repository at this point in the history
  • Loading branch information
t73biz committed Jul 18, 2024
1 parent 57051e1 commit 468d965
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/Components/Forms/Button.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class Button extends Component
* button: The button has no default behavior, and does nothing when pressed by default. It can have client-side
* scripts listen to the element's events, which are triggered when the events occur.
*/
public string $type = '';
public string $type = 'button';

/**
* Defines the value associated with the button's name when it's submitted with the form data. This value is
Expand Down Expand Up @@ -90,14 +90,12 @@ public function mount(): void
if (! empty($this->name)) {
$this->specificAttributes->add(['name' => $this->name]);
}
if (! empty($this->type)) {
if (! in_array($this->type, ['submit', 'reset', 'button'])) {
throw new InvalidAttributeException(
'The type attribute must be one of submit, reset, or button.'
);
}
$this->specificAttributes->add(['type' => $this->type]);
if (! in_array($this->type, ['submit', 'reset', 'button'])) {
throw new InvalidAttributeException(
'The type attribute must be one of submit, reset, or button.'
);
}
$this->specificAttributes->add(['type' => $this->type]);
if (! empty($this->value)) {
if (empty($this->name)) {
throw new InvalidAttributeException(
Expand Down

0 comments on commit 468d965

Please sign in to comment.