Skip to content

Commit

Permalink
fix: select multiple detection not strict
Browse files Browse the repository at this point in the history
  • Loading branch information
Gandhi11 committed Oct 31, 2023
1 parent beb14e9 commit af3a446
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
10 changes: 8 additions & 2 deletions src/Bootstrap4FormServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) ?? [];
}

Expand Down Expand Up @@ -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;
Expand Down
5 changes: 4 additions & 1 deletion src/Support/FormGroupBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down

0 comments on commit af3a446

Please sign in to comment.