From 08b0068a3aeb313aa6896215002aa42993afa940 Mon Sep 17 00:00:00 2001 From: Bart Jaskulski <bjaskulski@protonmail.com> Date: Wed, 6 Oct 2021 10:40:11 +0200 Subject: [PATCH] fix: prevent all empty attributes from being written to templates --- src/Field/Traits/HtmlAttributes.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Field/Traits/HtmlAttributes.php b/src/Field/Traits/HtmlAttributes.php index 4edae3b..e0fc3ba 100644 --- a/src/Field/Traits/HtmlAttributes.php +++ b/src/Field/Traits/HtmlAttributes.php @@ -33,13 +33,13 @@ trait HtmlAttributes { * * @return array<string[]|string|bool> */ - final public function get_attributes( array $except = [ 'name' ] ): array { + final public function get_attributes( array $except = [ 'name', 'method', 'action' ] ): array { return array_filter( $this->attributes, - static function ( $key ) use ( $except ) { - return ! in_array( $key, $except, true ); + static function ( $attribute, $key ) use ( $except ) { + return ! in_array( $key, $except, true ) && ! empty( $attribute ); }, - ARRAY_FILTER_USE_KEY + ARRAY_FILTER_USE_BOTH ); } -- GitLab