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(); }