Skip to content

Commit 7c4f12d

Browse files
authored
feat: adds enctype within the form component (#500)
1 parent 3c86f8e commit 7c4f12d

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/Tempest/View/src/Components/Form.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,21 @@ public static function getName(): string
1515
return 'x-form';
1616
}
1717

18+
public function isMultipart(GenericElement $element): bool
19+
{
20+
return $element->hasAttribute('enctype');
21+
}
22+
1823
public function render(GenericElement $element, ViewRenderer $renderer): string
1924
{
2025
$action = $element->getAttribute('action');
2126
$method = $element->getAttribute('method') ?? 'post';
27+
$enctype = $this->isMultipart($element)
28+
? "enctype=\"{$element->getAttribute('enctype')}\""
29+
: '';
2230

2331
return <<<HTML
24-
<form action="{$action}" method="{$method}">
32+
<form action="{$action}" method="{$method}" {$enctype}>
2533
<x-slot />
2634
</form>
2735
HTML;

0 commit comments

Comments
 (0)