From af3a44628155076ceaa3ecba1df475adc8b3d0eb Mon Sep 17 00:00:00 2001 From: Simon Gaudreau Date: Tue, 31 Oct 2023 11:11:42 -0400 Subject: [PATCH] fix: select multiple detection not strict --- src/Bootstrap4FormServiceProvider.php | 10 ++++++++-- src/Support/FormGroupBuilder.php | 5 ++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/Bootstrap4FormServiceProvider.php b/src/Bootstrap4FormServiceProvider.php index 7f32086..7c30c08 100644 --- a/src/Bootstrap4FormServiceProvider.php +++ b/src/Bootstrap4FormServiceProvider.php @@ -87,7 +87,13 @@ function ( $selected = null, array $selectAttributes = [], ): FormGroupBuilder { - if (is_null($selected) && in_array('multiple', $selectAttributes)) { + if ( + is_null($selected) && + ( + in_array('multiple', array_values($selectAttributes), true) || + array_key_exists('multiple', $selectAttributes) + ) + ) { $selected = Html::value($name) ?? []; } @@ -328,7 +334,7 @@ function ( public static function addTabIndexIfReadonly(array $attributes): array { if ( - (in_array('readonly', $attributes) || array_key_exists('readonly', $attributes)) && + (in_array('readonly', $attributes, true) || array_key_exists('readonly', $attributes)) && !array_key_exists('tabIndex', $attributes) ) { $attributes['tabIndex'] = -1; diff --git a/src/Support/FormGroupBuilder.php b/src/Support/FormGroupBuilder.php index 8000422..2c77dbe 100644 --- a/src/Support/FormGroupBuilder.php +++ b/src/Support/FormGroupBuilder.php @@ -308,7 +308,10 @@ public function select( $selected, )->attributes($this->parseInputOptions($selectAttributes)->all()); - if (in_array('multiple', $selectAttributes)) { + if ( + in_array('multiple', array_values($selectAttributes), true) || + array_key_exists('multiple', $selectAttributes) + ) { $this->input = $this->input->multiple(); }