diff --git a/src/Tags/Concerns/RendersAttributes.php b/src/Tags/Concerns/RendersAttributes.php index 5953ed570e..c5bb8a02db 100644 --- a/src/Tags/Concerns/RendersAttributes.php +++ b/src/Tags/Concerns/RendersAttributes.php @@ -37,15 +37,12 @@ protected function renderAttributes($attributes) /** * Render HTML attributes from tag params. * - * Parameters that are not prefixed with attr: will be automatically removed. - * + * @param array $except Parameters that should be excluded. Typically used for tag parameters that control behavior. * @return string */ - protected function renderAttributesFromParams() + protected function renderAttributesFromParams(array $except = []) { - $params = $this->params->filter(function ($value, $attribute) { - return preg_match('/^attr:/', $attribute); - })->all(); + $params = $this->params->reject(fn ($v, $attr) => in_array($attr, $except))->all(); return $this->renderAttributes($params); } @@ -55,11 +52,11 @@ protected function renderAttributesFromParams() * * @return string */ - protected function renderAttributesFromParamsWith(array $attrs) + protected function renderAttributesFromParamsWith(array $attrs, array $except = []) { return collect([ $this->renderAttributes($attrs), - $this->renderAttributesFromParams(), + $this->renderAttributesFromParams($except), ])->filter()->implode(' '); } } diff --git a/src/Tags/Concerns/RendersForms.php b/src/Tags/Concerns/RendersForms.php index 2f74515451..f80ba5c479 100644 --- a/src/Tags/Concerns/RendersForms.php +++ b/src/Tags/Concerns/RendersForms.php @@ -70,7 +70,10 @@ protected function formOpen($action, $method = 'POST', $knownTagParams = [], $ad $attrs['enctype'] = 'multipart/form-data'; } - $attrs = $this->renderAttributesFromParamsWith($attrs); + $attrs = $this->renderAttributesFromParamsWith( + $attrs, + except: array_merge(['method', 'action'], $knownTagParams) + ); $html = collect(['