From fb4a9d25a68ed6ef5461d4c7ba5c39b8a0b244d5 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 | 4 +++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/Bootstrap4FormServiceProvider.php b/src/Bootstrap4FormServiceProvider.php index 7f32086..7ee4e2c 100644 --- a/src/Bootstrap4FormServiceProvider.php +++ b/src/Bootstrap4FormServiceProvider.php @@ -87,7 +87,12 @@ 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) ?? []; } @@ -327,8 +332,7 @@ function ( */ public static function addTabIndexIfReadonly(array $attributes): array { - if ( - (in_array('readonly', $attributes) || array_key_exists('readonly', $attributes)) && + if ((in_array('readonly', $attributes) || 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..e10561c 100644 --- a/src/Support/FormGroupBuilder.php +++ b/src/Support/FormGroupBuilder.php @@ -308,7 +308,9 @@ 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(); }